PDA

Click to See Complete Forum and Search --> : ADO SQL query


ptran
Feb 16th, 2000, 09:56 PM
I have problem with the following code. The MANUFACTOR was selected from the Manufactor_model field in SQL table, but when I run this, the code CAN'T find the record. Do I need to add someting to the line sqltemp="select * from HWtable where Manufactor_model = '"& MANUFACTOR &"'", since the Manufactor_model field type is nvarchar?

Thanks....

<%
myDSN="DSN=INVENTORY;uid=xxx;pwd=xxx"
set conntemp=server.createobject("adodb.connection")
conntemp.open myDSN
MANUFACTOR=Request.QueryStrin("MANUFACTORY")

sqltemp="select * from HWtable where Manufactor_model = '"& MANUFACTOR &"'"

set rstemp = conntemp.execute(sqltemp)

PROCESSOR= rstemp("processor")
RAM_INSTALLED= rstemp("RAM_INSTALL")
RAM_MAX= rstemp("RAM_MAX")
VIDEO_CARD= rstemp("VIDEO_CARD")
VIDEO_MEM= rstemp("VIDEO_MEM")
RESOLUTION= rstemp("RESOLUTION")

rstemp.close
set rstemp=nothing
conntemp.close
set conntemp=nothing
%>

Marita_l
Feb 16th, 2000, 10:54 PM
Try using Like operator instead of equal. Sometimes this makes a differnce.

Clunietp
Feb 17th, 2000, 12:35 AM
What field in your DB is the INT type?

ptran
Feb 17th, 2000, 11:00 AM
Didn't work with like. I wonder if the field manufactor_model being a nvarchar have to with it.

Marita_l
Feb 17th, 2000, 11:35 AM
Are you getting any syntax errors or is it just returning no records found.

It appears as if you are not checking to see if MANUFACTOR has something in it. try putting in an if something like this:

if Request.QueryStrin("MANUFACTORY") = "" Then
MANUFACTOR="%"
else
MANUFACTOR=Request.QueryStrin("MANUFACTORY")
end if

This will check for empty strings and handle blank fields in the sql query. You will still have to use the like operator for this.

If you have handled the empty string else where then sorry this probably won't help.

hope this is helpful

Marita_l

Clunietp
Feb 17th, 2000, 11:37 AM
You are missing the G at the end of QueryStrin, maybe that'll do it....but your code looks right unless you are not receiving the value of the manufacturer....try using response.write at various points to determine if your script is working correctly

ptran
Feb 17th, 2000, 11:52 AM
There is a response with reponse.write, I have no problem if I used the field with INT type. Any other suggestions?

Thanks...