Connection strings for SQL Server

ODBC
  • 复制到剪贴板标准连接(Standard Security)
    Driver={SQL Server};Server=Aron1;Database=pubs;Uid=sa;Pwd=asdasd;
  • 复制到剪贴板当服务器为本地时Server可以使用(local)
    Driver={SQL Server};Server=(local);Database=pubs;Uid=sa;Pwd=asdasd;
  • 复制到剪贴板当连接远程服务器时,需指定地址、端口号和网络库
    Driver={SQL Server};Server=130.120.110.001;Address=130.120.110.001,1052;Network=dbmssocn; Database=pubs;Uid=sa;Pwd=asdasd;
    说明:Address参数必须为IP地址,而且必须包括端口号
  • 复制到剪贴板信任连接(Trusted connection): (Microsoft Windows NT 集成了安全性)
    Driver={SQL Server};Server=Aron1;Database=pubs;Trusted_Connection=yes;
  • Driver={SQL Server};Server=Aron1;Database=pubs; Uid=;Pwd=;
  • 复制到剪贴板连接时弹出输入用户名和口令对话框
    Conn.Properties("Prompt") = adPromptAlways
    Conn.Open "Driver={SQL Server};Server=Aron1;DataBase=pubs;"
OLE DB, OleDbConnection (.NET)
  • 复制到剪贴板标准连接(Standard Security)
    Provider=sqloledb;Data Source=Aron1;Initial Catalog=pubs;User Id=sa;Password=asdasd;
  • 复制到剪贴板信任连接(Trusted connection)
    Provider=sqloledb;Data Source=Aron1;Initial Catalog=pubs;Integrated Security=SSPI;
  • 复制到剪贴板连接时弹出输入用户名和口令对话框
    Conn.Provider = "sqloledb"
    Conn.Properties("Prompt") = adPromptAlways
    Conn.Open "Data Source=Aron1;Initial Catalog=pubs;"
  • 复制到剪贴板通过IP地址连接
    Provider=sqloledb;Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=pubs;User ID=sa;Password=asdasd;
SqlConnection (.NET)
  • 复制到剪贴板标准连接(Standard Security)
    Data Source=Aron1;Initial Catalog=pubs;User Id=sa;Password=asdasd;
  • Server=Aron1;Database=pubs;User ID=sa;Password=asdasd;Trusted_Connection=False
  • 复制到剪贴板信任连接(Trusted connection)
    Data Source=Aron1;Initial Catalog=pubs;Integrated Security=SSPI;
  • Server=Aron1;Database=pubs;Trusted_Connection=True;
  • 复制到剪贴板通过IP地址连接
    Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=pubs;User ID=sa;Password=asdasd;
Data Shape
  • 复制到剪贴板MS Data Shape
    Provider=MSDataShape;Data Provider=SQLOLEDB;Data Source=Aron1;Initial Catalog=pubs;User ID=sa;Password=asdasd;

©2009 vhalpha#163.com 鲁ICP备09080449号