Friday, March 23, 2007

Connection strings in Web.Config to connect different databases.

1) SQL Server

appSettings
add key="SqlConnectionString" value="Server=ServerName;
DataBase=DataBaseName;User Id=sa;Password = sa"

/appSettings

Or

appSettings
add key="SqlConnectionString"
value="Server=(local);Database=DBName2;UID=sa;PWD= "

/appSettings

Or
appSettings add key ="SqlConnectionString" value="Provider=SQLOLEDB; Data Source=server_name_or_address; Initial Catalog=database_name; User ID=username; Password=password"
/appSettings

User System.Data.SqlClient namespace to open the connection

2) MS Access

appSettings
add key = "MsAccessConnectionString"
Value = "Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=c:\DB\Volume.mdb;"
/appSettings


User System.Data.Oledb namespace to open the connection

3) Oracle


appSettings
add key="OracleConnectionString"
Value="Provider=OraOLEDB.Oracle.1;
Password=mypass;
Persist Security Info=True;
User ID=me;
Data Source=DatabaseName;"
/appSettings


User System.Data.Oledb namespace to open the connection

4) LDAP


appSettings
add key="LDAPConnectString"
value="
LDAP://Domain.com/DC=Domain,
DC=com"
/appSettings


5) DB2

appSettings

add key="connMainDB1" value="data source=ipaddy;
initial catalog=db1;persist security info=False;
user id=blah;password=blah;workstation id=webserver;
packet size=4096"
/appSettings


4) Microsoft Access
Provider=MSDASQL; Driver={Microsoft Access Driver (*.mdb)}; DBQ=C:\path\filename.mdb;

5) Microsoft Excel
Provider=MSDASQL; Driver={Microsoft Excel Driver (*.xls)}; DBQ=C:\path\filename.xls;

6) Microsoft Text
Provider=MSDASQL; Driver={Microsoft Text Driver (*.txt; *.csv)}; DBQ=C:\path\;

DSN Connection


Provider=MSDASQL; DSN=data_source_name; UID=username; PWD=password;

No comments: