救一段vb连接sql2005的代码
救一段vb连接sql2005的代码,最好要完整一点的。
[解决办法]
dim conn as new adodb.connection
With conn
If .State = adStateOpen Then .Close
.ConnectionString = "driver=SQL Server;server=计算机名或IP地址;uid=sa;pwd=;database=数据库名"
.CommandTimeout = 0
.Open
End With
[解决办法]
dim conn as new adodb.connection
With conn
If .State = adStateOpen Then .Close
.ConnectionString = "driver=SQL Server;server=计算机名或IP地址;uid=sa;pwd=;database=数据库名"
.CommandTimeout = 0
.Open
End With
[解决办法]
VB6连接SQL2005 ,有没有代码?具体怎么实现?
下边是我用VB连接SQL2000的代码,具体连2005怎么写?
Public cn As New ADODB.Connection
cn.ConnectionTimeout = 1
cn.ConnectionString = "Provider=SQLOLEDB;Data Source=" & strRunServer & ";" & _
"Initial Catalog=" & strCatalog & ";User Id=" & strUserID & ";Password=" & strPwd
cn.CursorLocation = adUseClient
cn.Open
[解决办法]
楼主,我上边的代码就可以实现连接SQL2005,我刚刚调试通过,
strRunServer SQL2005数据库,一般是 "机器名\SQLEXPRESS"(sql2000没有\SQLEXPRESS)
strCatalog 是你要访问的数据库名
strUserID 登录的用户名sa,也可以是其他用户
Password 登录密码,你的SQL2005设置的Sa密码