Can I use a Query stored in an MS Access database from an ASP page?

N

Noozer

Currently, I do the following in my ASP pages when making use of an MS
Access database:

Dim adoCon, rsSet, strSQL

Set AdoCon = server.CreateObject("ADODB.Connection")
Set RsSet = Server.CreateObject("ADODB.RecordSet")

adoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.MapPath("MyDB.mdb")

strSQL="SELECT * FROM MyTable;"
rsSet.Open strSQL, adoCon
...do some stuff...
rsSet.Close
adoCon.Close

Set rsSet=Nothing
Set adoCon=Nothing

I have a couple queries stored in the database that I use when in MS Access.
Can I call these queries instead of using a string to specify the SQL
command?

The above seems kind of verbose for making use of a database. Can it be
simplified at all?

Thx!
 
B

Bob Barrows [MVP]

Noozer said:
Currently, I do the following in my ASP pages when making use of an MS
Access database:

Dim adoCon, rsSet, strSQL

Set AdoCon = server.CreateObject("ADODB.Connection")
Set RsSet = Server.CreateObject("ADODB.RecordSet")

adoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.MapPath("MyDB.mdb")

strSQL="SELECT * FROM MyTable;"
rsSet.Open strSQL, adoCon
...do some stuff...
rsSet.Close
adoCon.Close

Set rsSet=Nothing
Set adoCon=Nothing

I have a couple queries stored in the database that I use when in MS
Access. Can I call these queries instead of using a string to specify
the SQL command?

Certainly.
For a non-parameter saved query, it's as simple as:

set rs=createobject("adodb.recordset")
adoCon.NameOfSavedQuery rs

if not rs.eof then ...

If the query uses parameters, see:
http://groups-beta.google.com/group/microsoft.public.inetserver.asp.db/msg/b3d322b882a604bd

http://www.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&[email protected]

http://groups.google.com/groups?hl=...=1&[email protected]




HTH,
Bob Barrows

Bob Barrows
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top