Sample Connection String for ASP.NET

Expand / Collapse
 
     

Sample Connection String for ASP.NET


We support several types of databases such as MSSQL, MySQL, Excel, Excel 2007 and Access in ASP.net application. Here are some sample connection strings.

MSSQL

ASP.net connection

"Server=DB Server;Database=DB NAME;uid=DB ID;pwd=DB Password;" providerName="System.Data.SqlClient"


OLE DB connection string (DSNless Connection):

"Provider=SQLOLEDB;Data Source=DB Server;User Id=DB ID;Password=DB Password;Initial Catalog=DB NAME;"


ODBC connection string

"DSN=ODBC Name;User Id=DB ID;Password=DB Password;Initial Catalog=DB NAME;"


Please replace the word in red color into your database information. If you don't know your database information, you can read this article.
For example:
ODBC Name : The name of ODBC you created in control panel > database > ODBC
DB Server : sql3xx.mysite4now.com
DB Name : mydemodb_12345
DB ID : mydemoid_12345
DB Password : mydemopw


MySQL

OLE DB connection string (DSNless Connection):

"DRIVER={MySQL}; SERVER=DB Server; DATABASE=DB Name; USER=DB ID; PASSWORD=DB PASSWORD; OPTION=3;"


ODBC connection string (Requires a ODBC to be created first):

"DSN=ODBC Name;User=DB ID;Password=DB PASSWORD;Database=DB NAME;"

Please replace the word in red color into your database information.
For example:
ODBC Name : The name of ODBC you created in control panel > database > ODBC
IP Address : mysqlxxx.mysite4now.com
DB Name : mysqldemo_12345
DB ID : mysqldemo_12345
DB Password : mysqlpw



Excel

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=path of excel;Extended Properties=Excel 8.0"

Replace
path of excel by the actual path of your excel file.
Example : d:\hosting\member\memberID\myexcel.xls

PS. If you need to write data into your excel database, please grant write permission to the excel file.


Excel 2007

"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=path of excel;Extended Properties=Excel 12.0"

Replace path of excel by the actual path of your excel 2007 file.
Example : d:\hosting\member\memberID\myexcel2007.xlsx

PS. If you need to write data into your excel database, please grant write permission to the excel file.

Access


For Access DB WITHOUT password protection:

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=path of access db"


For Access DB WITH password protection:

"Provider=MSDASQL;DRIVER={Microsoft Access Driver (*.mdb)};DBQ=path of access db;password=password of db"


Replace path of access db by the actual path of your excel 2007 file.
Example : d:\hosting\member\memberID\myAccessDB.mdb

Replace 
password of db by the database password of your Access database.







Add Your Comments


Name: *
Email Address:
Web Address:
Verification Code:
*
 

Details
Last Modified:5/31/2009 10:25 PM
Last Modified By: Mark
Type: FAQ
Article not rated yet.
Article has been viewed 4,366 times.
Options