Click to See Complete Forum and Search --> : ASP


Yan Cui
September 19th, 2000, 03:16 PM
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?

mlacinik
September 26th, 2000, 12:41 PM
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

skraotandra
December 13th, 2000, 02:08 PM
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.