Your question is vauge re. what you want to use to connect to Access
via ADO: what technology are you using to connect to Access?
Here are two connection methods:
ASP connection to Access (for a web page):
<%
'-- Declare your variables
Dim DataConnection, myRS, DBFileName
' Change the db1.mdb to <yourfilename>.mdb
DBFileName = "MyDB.mdb"
'-- Create dataconnection and recordset object and open database
Set DataConnection = Server.CreateObject("ADODB.Connection")
Set myRS = Server.CreateObject("ADODB.Recordset")
DataConnection.Open = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="
& Server.MapPath("\") & "\MyDB.mdb;"
%>
COMMENTS: this is a DSN-less connection, which means you don't have
to set up a reference to the Access db in the ODBC control panel,
which means less maintenance overhead for the server and less
processing resources for creating the connection needed. The
Server.MapPath stuff allows you to make a relative reference to the
Access db (as long is it is in the webserver Root or a subfolder).
After setting up the commands to open the db as DataConnection, you
will need to write an appropriate SQL statement and create a
recordset:
mySQL = "SELECT [fields] FROM [TABLE] WHERE [Condition];"
myRS.Open mySQL, DataConnection, adOpenStatic, adCmdTable
Conmment: the last two specifications are Cursor type declaration
(OpenStatic) and what object is being operated on in the
DataConnection (CmdTable). Depending on your needs, you may want
other cursor types, etc.
****
ADO in Access
You can also try to connect to an Access db in Access (VBA) and ADO is
a way to do it, but DAO is recommended. Using DAO for connection in
VBA to an Access table is trivial:
Dim rst As DAO.Recordset
' Access the query results
Set rst = CurrentDb.OpenRecordset("TableName", dbOpenDynaset)
COMMENTS: this illustrates connection using DAO in an Access VBA
module to open a table in the same database. Notice Set rst =
CurrentDB. Also the table name and cursor type is specified in the
parenthesis. If you want to connect to another Access db you will
have to supply information for that db and, as in the ASP example, you
may need to assign a cursor to your recordset that is good for your
purposes.
ASP is generic enough to transfer to other technologies, so it is
useful to understand, even if you are not using ASP to connect to
Access. |