Connecting to Access Database

Results 1 to 2 of 2

Thread: Connecting to Access Database

  1. #1
    Join Date
    Dec 1969

    Default Connecting to Access Database

    I am kind of new to ASP. I am trying to get data to my ASP pages from an Access database. My question is :<BR>Do I have to use DSN based connection to do this? or can I do the same thing with DSN-less connection?<BR>I have noticed Web hosting companys charge additional for DSN connections.<BR>Explnation with an example is greatly appreciated. Thank You.

  2. #2
    Join Date
    Dec 1969

    Default RE: Connecting to Access Database

    Web hosts typically give DSN connections because they are easier to use by people not familiar with code connections. You can use a DSNless connection which would look like the following. This is a snippet of code I use on my web site:<BR><BR>strDSN = "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("Addresses.mdb")<BR><BR>set oConn = Server.CreateObject("ADODB.Connection")<BR>oConn.O pen strDSN<BR><BR><BR>There&#039s your open connection! Notice that my database path is just "Addresses.mdb". This assumes that the database is in the same directory as the ASP files using it. You could use a virtual path, like "/bin/databases/mydb.mdb", or you could replace the whole Server.Mappath thing if you knew the file path to your database (e.g "F:Databasesmydb.mdb").<BR><BR>Hope that helps!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts