Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Can I use a Query stored in an MS Access database from an ASP page?

Reply
Thread Tools

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

 
 
Noozer
Guest
Posts: n/a
 
      07-21-2005
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!


 
Reply With Quote
 
 
 
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      07-21-2005
Noozer wrote:
> 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/...d322b882a604bd

http://www.google.com/groups?hl=en&l...TNGP12.phx.gbl

http://groups.google.com/groups?hl=e...tngp13.phx.gbl




HTH,
Bob Barrows

Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Database Database Database Database scott93727@gmail.com Computer Information 0 09-27-2012 02:43 AM
DataBase DataBase DataBase DataBase scott93727@gmail.com Computer Information 0 09-26-2012 09:40 AM
MS Access Query - use like stored procedure? Brenda Pasquarello ASP .Net 1 03-08-2006 12:46 PM
Binary data stored in SQL Server: can't read from ASP.NET, *can* read from Access? Doug ASP .Net 3 11-04-2005 07:35 PM
How to handle Access stored query with parameter in ASP page Jack ASP General 1 12-16-2004 08:17 PM



Advertisments