The Search Huts Articles Main Portal
 
Category Menu
Visual Basic
Search Engines
Javascript
Windows Tips
Photography
ASP
 RSS Feeds


Search in news :

A sample of Database Connection Strings

Category »  ASP
Posted By Guido on 24 March 2006
Comments   |   Print   |   Mail it
A sample of Database Connection Strings

If you want to call a database from within an asp page the first thing you will need to do is create a  database connection ie 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 used [ ] bracets these should be changed to < > just so you know I have also indicated where the code starts and finishes in red don't include the bits in red!


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.


Guido



Powered by Active News

Powered by Active News Manager - gazatem.com

HOME | REGISTER | CONTACT

Copyright John Hutchison © 2000-2006

eXTReMe Tracker