|
 |
access_asp thread: Calling Saved Access Queries in ASP
Message #1 by "Young, Ashley" <Ashley.Young@c...> on Fri, 25 Oct 2002 17:23:41 -0400
|
|
Once again, I have a question. Is it possible to call the queries you have
saved in Access through ASP? I want to call the saved query and display the
results on a webpage. As always, details are very much appreciated.
Thanks,
--Ashley
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.377 / Virus Database: 211 - Release Date: 7/15/2002
Message #2 by "Rob Parkhouse" <rparkhouse@o...> on Mon, 28 Oct 2002 00:58:27
|
|
> Once again, I have a question. Is it possible to call the queries you
have
saved in Access through ASP? I want to call the saved query and display the
results on a webpage. As always, details are very much appreciated.
Thanks,
--Ashley
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.377 / Virus Database: 211 - Release Date: 7/15/2002
Yes you can do this. It may be as simple as using a query name rather than
table name when opening a recordset.
If the query has run time parameters that are not constants, you will have
to substitute the parameters in the ASP code. I have patched some sample
code I used once as an example. This query when executed in Access
obtained parameters from a form (dlgIndiv). Rather than alter the query
for the ASP I used the same parameter reference. Looks a bit dumb in the
ASP, but it let me use the query from both Access and ASP. Hope it helps:
<%
dim objComm, objParam, strConnect
' Setup strConnect etc
Set objComm = Server.CreateObject("ADODB.Command")
objComm.ActiveConnection = strConnect
objComm.CommandText = "myAccessQuery"
objComm.CommandType = adCmdStoredProc
' define the query parameters
Set objParam = objComm.CreateParameter("[Forms]![dlgIndiv]!
[CGid]",adVarChar,adParamInput,50)
objComm.Parameters.Append objParam
Set objParam = objComm.CreateParameter("[Forms]![dlgIndiv]!
[Empid]",adVarChar,adParamInput,50)
objComm.Parameters.Append objParam
Set objParam = objComm.CreateParameter("[Forms]![dlgIndiv]!
[SurveyCode]",adVarChar,adParamInput,50)
objComm.Parameters.Append objParam
Set objParam = objComm.CreateParameter("[gap]",adSingle,adParamInput,10)
objComm.Parameters.Append objParam
' set the query parameter values
objComm.Parameters("[Forms]![dlgIndiv]![CGid]") = CGid
objComm.Parameters("[Forms]![dlgIndiv]![Empid]") = Empid
objComm.Parameters("[Forms]![dlgIndiv]![SurveyCode]") = SurveyCode
objComm.Parameters("[gap]") = gap
' execute the query
Set objRS = objComm.Execute
Set objParam = Nothing
Set objComm = Nothing
%>
Good luck
|
|
 |