NET, ASP.NET, AJAX, ASP.NET AJAX, JavaScript, WEB, WEB2.0, Neoking, Neoayi, Microsoft, SilverLight, CSS
代码改变世界

在线数据库链接字符串查询

2007-08-23 10:51  黄明  阅读(624)  评论(0编辑  收藏  举报
http://www.connectionstrings.com/

我常用的
MS SQL2005
SQL Native Client OLE DB Provider


Standard security
Provider=SQLNCLI;Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;


Trusted connection

Provider=SQLNCLI;Server=myServerAddress;Database=myDataBase;Trusted_Connection=yes;


Prompt for username and password

oConn.Properties("Prompt") = adPromptAlways
oConn.Open "Provider=SQLNCLI;Server=myServerAddress;DataBase=myDataBase;


Attach a database file on connect to a local SQL Server Express instance

Provider=SQLNCLI;Server=."SQLExpress;AttachDbFilename=c:"asd"qwe"mydbfile.mdf; Database=dbname;Trusted_Connection=Yes;


Attach a database file, located in the data directory, on connect to a local SQL Server Express instance

Provider=SQLNCLI;Server=."SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf; Database=dbname;Trusted_Connection=Yes;


Database mirroring

Data Source=myServerAddress;Failover Partner=myMirrorServer;Initial Catalog=myDataBase;Integrated Security=True;

SqlConnection (.NET)


Standard Security
Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;


Standard Security alternative syntax
Server=myServerAddress;Database=myDataBase;User ID=myUsername;Password=myPassword;Trusted_Connection=False;


________________________________________________________________________________________

Context Connection

C#
 using(SqlConnection connection = new SqlConnection("context connection=true"))
 {
     connection.Open();
     // Use the connection
 }

VB.Net
 Using connection as new SqlConnection("context connection=true")
     connection.Open()
     ' Use the connection
 End Using

________________________________________________________________________________________




MS Access 2007


Standard security
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:"myFolder"myAccess2007file.accdb;Persist Security Info=False;


With database password
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:"myFolder"myAccess2007file.accdb;Jet OLEDB:Database Password=MyDbPassword;