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

Open Access database using SQL string

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
US
I have this code which works fine

<%
Set fp_conn = Server.CreateObject(&quot;ADODB.Connection&quot;)
Set fp_rs = Server.CreateObject(&quot;ADODB.Recordset&quot;)
fp_conn.Open Application(&quot;tellusaboutyou_ConnectionString&quot;)
fp_rs.Open &quot;test&quot;, fp_conn, 1, 3, 2 ' adOpenKeySet, adLockOptimistic, adCmdTable
fp_rs.movefirst
Response.Write &quot;Name: &quot; & fp_rs(&quot;name&quot;)
fp_rs.Close
fp_conn.Close
%>

But rather than open the table I want to be able to open a recordset using a SQL string like so
SQLString = &quot;Select * from test&quot;

but this gives the error
-------------------
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC Microsoft Access Driver] Syntax error in FROM clause.

/test.asp, line 17
---------------------
....
SQLString = &quot;Select * from test&quot;
fp_rs.Open SQLString, fp_conn, 1, 3, 2 ' adOpenKeySet, adLockOptimistic, adCmdTable
---------------------------------
this is line 17
fp_rs.Open SQLString ....

Can you advise on the correct syntax ????





DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 


DougP,

In your open string, use the query:

fp_rs.Open &quot;Select * from test&quot;, fp_conn, 1, 3, 2


fp_rs Should contain the record set you are looking for.

Cheers,
fengshui1998

 
I changed this

SQLString = &quot;Select * from test&quot;
fp_rs.Open SQLString, fp_conn, 1, 3, 2

to this

SQLString = &quot;Select * from test&quot;
fp_rs.Open SQLString, fp_conn, 3, 3 '<<< note different parameters here

and it works perfect DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top