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

calling Access query with parameter from ASP

Status
Not open for further replies.

Rydel

Programmer
Joined
Feb 5, 2001
Messages
376
Location
CZ
Dear gurus,

I have a question on how to call query with a parameter from ASP pages. To illustrate my problem with an example let's say, I have myDB.mdb and in it I have the following query named myQuery:

Code:
PARAMETERS currAge;
SELECT * FROM experts WHERE Age>currAge;

I also have something like this in an ASP file:

Code:
set cnn = Server.CreateObject("ADODB.Connection")
cnn.Open "driver={Microsoft Access Driver *.mdb)};;DBQ=d:/myDB.mdb;"
strSQL = ???????? ' here I want to call the above query and supply the parameter currAge!
set Results = cnn.Execute(strSQL)

Question: what goes into strSQL=?????? instead of question marks to call the Access query and supply the parameter for it.

Thanks a lot in advance! ---
---
 
Have you found the answer for your problem ? Thanks!

RR


 
this will work . I use it.


<%
Set cn = Server.CreateObject (&quot;ADODB.connection&quot;)
Set cmd = server.CreateObject (&quot;ADODB.command&quot;)
Set rs = Server.CreateObject(&quot;ADODB.Recordset&quot;)
cn.Open &quot;Driver={Microsoft Access Driver (*.mdb)};&quot; & _
&quot;DBQ=C:\Inetpub\ With cmd
.CommandText = &quot;Query1&quot;
Set .ActiveConnection = cn
End With

'rs.CursorLocation = adUseClient

set rs = cmd.Execute'

while not rs.eof
Response.write (rs(0))
rs.MoveNext
wend
rs.Close
cn.Close
%>
</table>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top