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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

strSQL1 ="SELECT * FROM "& doc &" WHERE number=" &am

Status
Not open for further replies.

jcroft

Programmer
Aug 23, 2001
52
0
0
US
THE CODE BELOW produces the ERROR BELOW

con1 = "DSN=QC4ID"
set rs1 = server.CreateObject("ADODB.Recordset")
strSQL1 ="SELECT * FROM "& doc &" WHERE number=" & snum
rs1.Open strSQL1, con1,1,3
picture = rs1("filename")


Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[Microsoft][ODBC Microsoft Access Driver] Syntax error in query. Incomplete query clause.

/qc4id/doc.asp, line 31

I have tried:
strSQL1 = "SELECT * FROM '" & doc & "'" &" WHERE number=" & snum
and 2 dozen similar versions.

The variable used in the table position is the troublemaker but I don't know how to fix it.

Help Please,
JC


--only those that do not try, fail--
 
Have you did a response write to see what is actually in the SQL string that you are creating? that is the first thing I would try - that way you can see what is actually being generated abd sent to the database and you can probably figure out why it isn't working if you see what is actually there. Let us know what you find.
 
A problem I run into sometimes is that since everything in VBScript is typed a variant, you need to specifically type the snum variable. if it is an int in the database the change the query to use the cint() of clng() functions to type your snum variable as show below:

strSQL1 = "SELECT * FROM '" & doc & "'" &" WHERE number=" & cint(snum)


 
SELECT * FROM ''cr'' WHERE number=13450

is the response from response.write for:

strSQL1 = "SELECT * FROM '" & doc & "'" &" WHERE number=" & clng(snum)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SELECT * FROM 'cr' WHERE number=13450

is the response from response.write for:

strSQL1 = "SELECT * FROM " & doc &" WHERE number=" & clng(snum)

I still get the same error for both...doc is variable for the name of the table in the database and I think it is the culprit
--only those that do not try, fail--
 
Thank you, it worked.
--only those that do not try, fail--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top