Tuesday 21 August 2012

ASP: database connection strings (basic)

   


After a few days of deserved rest, here we get back to work! No that I want to, but I'm sure you are all waiting for new posts ... ... ... or not?

In the following short article I would like to list all possible database connection strings, just in case you need them in your projects. We will see just the basic way of connecting to data sources, so keep in mind that specific additional security parameters may be used, in case you need them.
Ready? Then please follow me...

Here is the list! I divided it into different sections, so that it might be easier to find what needed.

SQL Server
Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;

Access 2007 (OLEDB 12.0)
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\Access2007File.accdb;Persist Security Info=False;

Access
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\myDB.mdb

Exchange
ExOLEDB.DataSource
We need to specify the "store" in the connection open command. An example:
conn.open "http://ServerName/PublicStoreName"

System DSN
DSN=myDsn;Uid=myUsername;Pwd=;

File DSN
FILEDSN=c:\myDsnFile.dsn;Uid=myUsername;Pwd=;

Excel
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MyExcelFile.xls;Extended Properties="Excel 8.0;HDR=Yes;IMEX=1";

Excel 2007
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\MyExcel2007file.xlsx;Extended Properties="Excel 12.0 Xml;HDR=YES";
"HDR=Yes;" indicates that the first row contains column names, and not data. "HDR=No;" obviously indicates tha there are no column names.

Ok, that's all for today. If you need to add something, please use the comments section below.

0 thoughts:

Post a Comment

Comments are moderated. I apologize if I don't publish comments immediately.

However, I do answer to all the comments.