Posted on 2005-08-16 08:35
woow 阅读(302)
评论(0) 编辑 收藏 引用
· SqlConnection (.NET)
o 标准连接(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"
(这两个连接串的结果相同)
o 信任连接(Trusted connection):
"Data Source=Aron1;Initial Catalog=pubs;Integrated Security=SSPI;"
或者
"Server=Aron1;Database=pubs;Trusted_Connection=True;"
(这两个连接串的结果相同)
(可以用serverName\instanceName代替Data Source,取值为一个具体的SQLServer实例,但仅适用于 SQLServer2000)
o 通过IP地址连接:
"Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=pubs;User ID=sa;Password=asdasd;"
(DBMSSOCN=TCP/IP代替Named Pipes, Data Source的末尾是需要使用的端口号(缺省为1433))
o SqlConnection连接的声明:
C#:
using System.Data.SqlClient;
SqlConnection SQLConn = new SqlConnection();
SQLConn.ConnectionString="my connectionstring";
SQLConn.Open();
VB.NET:
Imports System.Data.SqlClient
Dim SQLConn As SqlConnection = New SqlConnection()
SQLConn.ConnectionString="my connectionstring"
SQLConn.Open()
·o 标准连接:
"Data Source=Oracle8i;Integrated Security=yes";
这只对Oracle 8i release 3或更高版本有效
o OracleConnection声明:
C#:
using System.Data.OracleClient;
OracleConnection OracleConn = new OracleConnection();
OracleConn.ConnectionString = "my connectionstring";
OracleConn.Open();
http://erwin.softwarechn.com/view.asp?ID=191
Conn="server=localhost;uid=sa;pwd=sa;database=flyring
SQLServer是采用集成登录的,而现在用uid,pwd也就是混合登录,所以会被
SQLServer拒绝
"Data Source=(local);Intergrated Security=SPII;Initial Catalog=Flyring");
conn ="server=localhost;database=flyringIntegrated Security=SSPI;Persist Security Info=False;"