Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What am I doing worng? 1

Status
Not open for further replies.

Cirrus9

IS-IT--Management
Aug 21, 2001
248
US
I keep getting errors and I know it's probably something basic that I am overlooking.

I am passing a variable from a form. I have tested the variable and it works.
This code is intended to check for a code in the database that matches the request form variable.


If not isempty(request.form("code"))then

'test for code
response.write RS("code")

Set MyConn = Server.CreateObject("ADODB.Connection")
set RS = Server.CreateObject("ADODB.Recordset")
MyConn.Open ("DSN=school")

SQL_Query=("SELECT * FROM log WHERE code = " & request.form("code"))

Set RS = MyConn.Execute(SQL_Query)

Do Until RS.EOF

RS("code")

rs.MOVENEXT

loop

else

response.write("Sorry your code does not match a known record")

end if





If anyone knows what I am missing, pleae let me know. Thanks
 
what is the datatype of the code...try this:

SQL_Query=("SELECT * FROM log WHERE code = '" & request.form("code") &"' ")

-DNG
 
I tried it and it returns the "Sorry your code does not match a known record" message when using a known code.

There are no errors. It just won't seem to recognize the data. I checked and rechecked the field names and they are correct.

The data type is set to text in MS access 2003.

 
try this:

Code:
 Set MyConn = Server.CreateObject("ADODB.Connection")
 set RS = Server.CreateObject("ADODB.Recordset")
 MyConn.Open ("DSN=school")
 
SQL_Query=" SELECT code FROM log WHERE code = '" & request.form("code") &"' "  

Set RS = MyConn.Execute(SQL_Query)

if rs.EOF AND rs.BOF then
response.write "Sorry code not found"
else
response.write "code found."
end if

-DNG
 
It works!
I decided to check my referring page and found that in the post method, I inserted the wrong encrytion type.

Thanks for all of your help, you definitely steered me in the right direction with the syntax for the SQL query.

Thanks

 
no problem...glad to help...


your sql query would have worked fine if the data type of the field code was numeric...

-DNG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top