需要将SQL Server 2005与vb6连接。
我有以下代码..
我必须更改用户名和密码才能打开软件。 但是在Windows身份验证中打开,
Public Sub OpenConn()
If Cn.State = 1 Then Cn.Close
'sql 2000 sql authentication
Cn.ConnectionString = "Provider=sqloledb; Data Source=Guru;Initial Catalog=eIntelliCabs;User Id=w[enter image description here][1]indowsusername;Password=windowsloginpassword;"
'sql 2005 /2008 express windows authetication
'Cn.ConnectionString = "Provider=sqloledb;Data Source=maity;Initial Catalog=eIntelliCabs;User Id=sa;Password=123;"
Cn.CursorLocation = adUseClient
Cn.Open
请帮我解释一下代码。
答案 0 :(得分:2)
要使用SQL身份验证,请尝试:
Cn.ConnectionString = "Provider=SQLNCLI10;Server=ServerName\SQLExpress;AttachDbFilename=c:\YourPath\mydbfile.mdf;Database=dbname;Uid=myUsername;
Pwd=myPassword;"
要使用Trusted Security(Windows身份验证),请尝试:
Cn.ConnectionString = "Provider=SQLNCLI10;Server=ServerName\SQLExpress;AttachDbFilename=c:\YourPath\mydbfile.mdf;Database=dbname;Trusted_Connection=Yes;
了解详情