时间:2021-07-01 10:21:17 帮助过:2人阅读
Provider = SQLNCLI10;Server = .\SQLExpress;AttachDbFilename = c:\asd\qwe\mydbfile.mdf; Database = dbname;
Trusted_Connection = Yes;
Provider = SQLNCLI10;Server = .\SQLExpress;AttachDbFilename = |DataDirectory|mydbfile.mdf;
Database = dbname;Trusted_Connection = Yes;
Provider = SQLNCLI10;Data Source = myServerAddress;Failover Partner = myMirrorServerAddress;Initial
Catalog = myDataBase;Integrated Security = True;
三、.NET Framework Data Provider for OLE DB
类型:.NET Framework Wrapper Class Library
使用:System.Data.OleDb.OleDbConnection
厂商:Microsoft
Provider = SQLNCLI10;Server = myServerAddress;Database = myDataBase;Uid = myUsername; Pwd = myPassword;
四、SQL Server Native Client 10.0 ODBC Driver
类型:ODBC Driver
使用:Driver={SQL Server Native Client 10.0}
厂商:Microsoft
Driver = {SQL Server Native Client 10.0};Server = myServerAddress;Database = myDataBase;Uid = myUsername;Pwd = myPassword;
Driver = {SQL Server Native Client 10.0};Server = myServerAddress;Database = myDataBase;Trusted_Connection = yes;
Driver = {SQL Server Native Client 10.0};Server = myServerName\theInstanceName;
Database = myDataBase;Trusted_Connection = yes;
oConn.Properties("Prompt") = adPromptAlways
Driver = {SQL Server Native Client 10.0};Server = myServerAddress;Database = myDataBase;
Driver = {SQL Server Native Client 10.0};Server = myServerAddress;Database = myDataBase;Trusted_Connection = yes;
MARS_Connection = yes;
Driver = {SQL Server Native Client 10.0};Server = myServerAddress;Database = myDataBase;
Trusted_Connection = yes;Encrypt = yes;
Driver = {SQL Server Native Client 10.0};Server = .\SQLExpress; AttachDbFilename = c:\asd\qwe\mydbfile.mdf;
Database = dbname;Trusted_Connection = Yes;
Driver={SQL Server Native Client 10.0};Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf;
Database=dbname;Trusted_Connection=Yes;
Driver = {SQL Server Native Client
10.0};Server = myServerAddress;Failover_Partner = myMirrorServerAddress;Database = myDataBase; Trusted_Connection = yes;
五、.NET Framework Data Provider for ODBC
类型:.NET Framework Wrapper Class Library
使用:System.Data.Odbc.OdbcConnection
厂商:Microsoft
下面的语句只是一条例子,不同厂商的ODBC驱动不同。
Driver={SQL Server Native Client 10.0};Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
六、SQLXML 4.0 OLEDB Provider
类型:OLE DB Provider
使用:Provider=SQLXMLOLEDB.4.0;Data Provider=providername
厂商:Microsoft
Provider=SQLXMLOLEDB.4.0;Data Provider=SQLNCLI10;Data Source=myServerAddress;Initial Catalog=myDataBase;User
Id=myUsername;Password=myPassword;
七、Context Connection
类型:.NET Framework Class Library
使用:
厂商:Microsoft
通过当前CLR里的存储过程/函数来连接到“自身”。上下文连接可以让你,在你的代码第一次被调用的地方所在的上下文(连接)里,执行T-SQL语句。
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
SQL Server 2008连接字符串写法大全
标签: