Divi WordPress Theme

Topic: Various Connection Strings to Connect to an Access DB  (Read 3634 times)

Offline Tech

  • Junior Guru
  • **
  • Posts: 183
  • iTrader: +2/-0
    • View Profile
Various Connection Strings to Connect to an Access DB
« on: August 29, 2007, 02:22:08 AM »
If you want to call a database from within an asp page the that is to tell your asp page where your database is. Here are a few samples of database connection strings that could be used to help you connect to your database I have also indicated where the code starts and finishes. I have used [] as the normal < > makes it impossible to see the code in the finished article as the page thinks it is real code so does not display it. If you want to use any of the code remember to change the square brackes [] to <>

OLE DB Method for SQL

'code start
[% set cnn = server.createobject("ADODB.Connection") cnn.open "PROVIDER=SQLOLEDB;DATA SOURCE=sqlservername;UID=username;PWD=password;DATABASE=dbname.mdb " %]
'code finish

DSN-Less connection for Access

'code start
[% set cnn = server.createobject("ADODB.Connection") cnn.open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=c:yourdatabase.mdb" %]
'code finish

OLE DB Method for Access

'code start
[% set cnn = server.createobject("ADODB.Connection") cnn.open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=c:yourdatabase.mdb" %]
'code finish

File DSN Connection Method for Access

'code start
[% set cnn = server.createobject("ADODB.Connection") cnn.open "FILEDSN=AccessDSN" %]
'code finish

Don't forget when you download an application this info should be included. Remember to RENAME the database as others can download the application from where you did and see what the default name is if your page is live ie on the web and you have not renamed the database they could easily download your database and add or change information contained in the database. I had this happen a few years ago and all the links pointed to porn sites luckily I did not have many visitors in those days. So remember change the database name and possibly the directory that the database is in.

Article Source: http://EzineArticles.com/?expert=John_Hutchison
« Last Edit: January 01, 1970, 05:30:00 AM by Tech »
VPS Hosting - AccuWebHosting

Offline digitalpoint

  • New Member
  • *
  • Posts: 45
  • iTrader: +0/-0
    • View Profile
Re: Various Connection Strings to Connect to an Access DB
« Reply #1 on: May 14, 2009, 11:43:46 AM »
Thanks for sharing such useful information.

Offline subhaikav

  • Newbie
  • *
  • Posts: 5
  • iTrader: +0/-0
    • View Profile
Re: Various Connection Strings to Connect to an Access DB
« Reply #2 on: June 25, 2009, 11:09:23 AM »
Thank you for the post.. It really helps a lot..

Offline jeffreykirwin

  • Newbie
  • *
  • Posts: 2
  • iTrader: +0/-0
    • View Profile
Re: Various Connection Strings to Connect to an Access DB
« Reply #3 on: October 13, 2015, 09:54:54 AM »
Access File Recovery Software is an intelligent solution to fix all corruption issues in ACCDB and MDB database files and saves all the deleted records and objects like indexes, queries, relations and tables, on new database. See full info :- http://www.mannatsoftware.com/stellar-phoenix-access-recovery.html

Divi WordPress Theme
Tags: