CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: ASP

  1. #1
    Join Date
    Sep 2000
    Posts
    5

    ASP

    I wrote an ASP to receive a string from a XML form and use the string received to search records in a table. It didn't work. I can't find the problem. Here is the code:

    dim code, name 'hold the textbook code and name
    dim addcomment 'hold the link to the addbkcomment.asp
    dim rs, cn, sql
    dim xmldoc, xsldoc
    set xmldoc=Server.CreateObject("Microsoft.XMLDOM") 'create an empty XML document
    code = Request.form("bkcode") 'get the book code from the client
    name = Request.form("bktitle") 'get the book title from the client

    set rs = Server.CreateObject("ADODB.Recordset")
    set cn = Server.CreateObject("ADODB.Connection")

    addcomment = "addbkcomment.asp?bkcode=" & code & "&bktitle=" &name

    'find all the comments on the book
    cn.Open "DSN = YanPrj"

    sql = "select * from BkComment where BookCode='"&code&"'"
    rs.Open sql, cn

    I checked the value of code, it did contain the right value. If I change the where clause to "where BookCode = 'b1000'", it did return all the comments that match the BoodCode b1000. Could someone help me?





  2. #2
    Join Date
    Aug 2000
    Location
    Germany
    Posts
    16

    Re: ASP

    It could be possible that the datatype does not match with the datatype in your database
    Try to convert it into the right type.

    example:

    code = CLng(Request.Form("bkcode")) 'for long

    or..

    code = CInt(Request.Form("bkcode")) 'for int

    and so on....

    hope it helps.

    ;-) Mario




  3. #3
    Join Date
    Dec 2000
    Posts
    2

    Re: ASP

    why dont u try using trim on the variable code as it may contain spaces which do not match with the datat in the table.
    Ex: Where BookCode = Trim('" & code & "')

    best of luck.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured