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

Connection Strings for Access 2002

Status
Not open for further replies.

blondebier

Programmer
Jun 19, 2003
142
0
0
GB
Which is the best connection string to use for an database created in Access 2002?

I've been using this one:

strConn = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("myDB.mdb")
 
You could use DSN connection to do this. First, create a folder in your web directory called Includes. In this folder create a file called MyDataConnection. It's name will look like this MyDataConnection.inc

Be sure that the extension is .inc. This is what's known as an include file. Now in this file place this copy and past this code:

<%
Dim cmdDC, Recordset, SearchText, Cnt
SearchText = Request.Form(&quot;txtSearchText&quot;)

Set Conn = Server.CreateObject (&quot;ADODB.Connection&quot;)
conn.open &quot;ASPPages2&quot;
Set cmdDC = Server.CreateObject(&quot;ADODB.Command&quot;)
cmdDC.ActiveConnection = Conn

%>

This is your connection code. Now in the page that you will be using to either view or post data to you db, put this at the very top of the page.

<!--#include file=&quot;includes/FTEStaffing.inc&quot;-->

This one like can be used to connect any page in your website to the database. Now after you have done this, at the bottom of this webpage put this code below the html of the page.

<%
'-- Close database and release

RecordSet.Close
Set RecordSet = Nothing

Set cmdDC = Nothing
Conn.Close
Set Conn = Nothing
%>

as the notation says, this closes your connection an TAA DAA!! you have your connection. Try it out.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top