这是个专门提供连接字符串的网站,支持的数据库包括:SQL Server、Oracle、IBM DB2、MySQL、Access、Excel、Textfile……
连接 SQL Server 2008/2005/2000:
Provider=SQLOLEDB;Data Source=(local);Initial Catalog=db;Integrated Security=SSPI;
Provider=SQLOLEDB;Data Source=(local);Initial Catalog=db;User ID=登录名;Password=密码;
连接 SQL Server 2008/2005 Express:
Provider=SQLOLEDB;Data Source=(local)\SQLEXPRESS;Initial Catalog=db;Integrated Security=SSPI;
Provider=SQLOLEDB;Data Source=(local)\SQLEXPRESS;Initial Catalog=db;User ID=登录名;Password=密码;
连接 SQL Server LocalDB(点我查看详细):
Data Source=(localdb)\MSSQLLocalDB; Initial Catalog=cftea; Integrated Security=SSPI; AttachDbFilename=D:\SQLData\cftea.mdf;
Data Source=(localdb)\MSSQLLocalDB; Initial Catalog=cftea; Integrated Security=SSPI;
Server=np:\\.\pipe\LOCALDB#C79106A6\tsql\query; Initial Catalog=cftea; Integrated Security=SSPI; AttachDbFilename=D:\SQLData\cftea.mdf;
Server=np:\\.\pipe\LOCALDB#C79106A6\tsql\query; Initial Catalog=cftea; Integrated Security=SSPI;
连接 Access 2007:
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Access2007文件位置;Persist Security Info=False;
连接 Access:
Provider=Microsoft.Jet.OleDb.4.0;Data Source=Access文件位置;
连接 Excel 2007:
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Excel2007文件位置;Extended Properties='Excel 12.0;HDR=NO;'
连接 Excel:
Provider=Microsoft.Jet.OleDb.4.0;Data Source=Excel文件位置;Extended Properties='Excel 8.0;HDR=NO;'
连接 MySQL:
driver={mysql odbc 3.51 driver};server=127.0.0.1;uid=uid;pwd=pwd;database=db
driver={mysql odbc 5.1 driver};server=127.0.0.1;uid=uid;pwd=pwd;database=db
web.config 中连接 SQL Server 2008/2005/2000:
<add name="MySqlServer" connectionString="Data Source=(local);Initial Catalog=db;Integrated Security=SSPI;" providerName="System.Data.SqlClient"/>
<add name="MySqlServer" connectionString="Data Source=(local);Initial Catalog=db;User ID=登录名;Password=密码;" providerName="System.Data.SqlClient"/>
web.config 中连接 SQL Server 2008/2005 Express:
<add name="MySqlServer" connectionString="Data Source=(local)\SQLEXPRESS;Initial Catalog=db;Integrated Security=SSPI;" providerName="System.Data.SqlClient"/>
<add name="MySqlServer" connectionString="Data Source=(local)\SQLEXPRESS;Initial Catalog=db;User ID=登录名;Password=密码;" providerName="System.Data.SqlClient"/>
web.config 中连接 App_Data 中的数据文件:
<add name="MySqlServer" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Data.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>