"WHERE (((Test.id)="' ??? "'');" (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


WRXSTi -> "WHERE (((Test.id)="' ??? "'');" (2/26/2002 10:13:50)

Below is my code. I want to capture the the id value from Querystring("id") and place it in the the WHERE condition below. It does'nt seem to be working. if I hard code a numeric value "WHERE (((Test.id)=2);" it works. If I use "WHERE (((Test.id)="' & CMD & "');" it fails?

What is the correct code ? I'm witing my asp and not letting FP write any dB code.

 
<%
user = Session("UserName")

'Get Querysting info.
CMD = Request.Querystring("id")

Set cnn1 = Server.CreateObject("ADODB.Connection")
openStr = "driver={Microsoft Access Driver (*.mdb)};" & _
"dbq=" & Server.MapPath("./fpdb/meatheads.mdb")
cnn1.Open openStr,"",""

sql = "SELECT Test.id, " & _
"Test.subject, " & _
"Test.condition, " & _
"Test.price, " & _
"Test.category, " & _
"Test.email, " & _
"Test.userid " & _
"FROM Test " & _
"WHERE (((Test.id)=' & CMD & ');"

Set rsMbrs = Server.CreateObject("ADODB.Recordset")
rsMbrs.Open sql, cnn1, adOpenForwardOnly, adLockReadOnly, adCmdText
%>


Me




ginnie -> RE: "WHERE (((Test.id)="' ??? "'');" (2/26/2002 10:31:11)

Try this, assuming Test.id is numeric:

"WHERE ((Test.id)=" & CMD & ");"

Or this if it's a string:

"WHERE ((Test.id)='" & CMD & "');"

Looks like you have an extra opening parenthesis in the "Where" line too.

NOTE: No apostrophes/single quotes around numeric fields, just text fields.

ginnie
Global Presence Web Design



Edited by - ginnie on 02/26/2002 10:34:05




WRXSTi -> RE: "WHERE (((Test.id)="' ??? "'');" (2/26/2002 10:50:25)

Test.id is a autonumber key value.

I changed the code to your suggestion of
"WHERE (((Test.id)=" & CMD & ");"
however I now get the following error when the page loads.
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC Microsoft Access Driver] Syntax error in query expression '(((Test.id)=3);'.

/testitemdetail.asp, line 32

Line 32 is (shown in previous post)
rsMbrs.Open sql, cnn1, adOpenForwardOnly, adLockReadOnly, adCmdText

Any thougths as why this is?

Me




ginnie -> RE: "WHERE (((Test.id)="' ??? "'');" (2/26/2002 10:59:36)

It looks like you didn't remove the extra opening parenthesis that I mentioned.

Should be:

"WHERE ((Test.id)=" & CMD & ");"

You have:

"WHERE (((Test.id)=" & CMD & ");"


Note the extra opening parenthesis around Test.id



ginnie
Global Presence Web Design




WRXSTi -> RE: "WHERE (((Test.id)="' ??? "'');" (2/26/2002 11:04:31)

Boy was that a bonehead move...

thank you very much.


Me




ginnie -> RE: "WHERE (((Test.id)="' ??? "'');" (2/26/2002 11:08:24)

You're welcome!

Me




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.0625