请各位帮忙vb连接SQL
Dim cnn1 As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strCnn As String
Dim varDate As Variant
strCnn = "Provider=sqloledb;" & _
"Data Source=localhost;Initial Catalog=wygl;User Id=sa;Password=; "
Set cnn1 = New ADODB.Connection
cnn1.Open strCnn
以上连接不知道出了什么问题,提示sqlserver不存在,或拒绝访问。
[最优解释]
将localhost改成计算机名或IP地址试试
[其他解释]
连接字符串你这样写看看: g_SqlDBString = "DRIVER={SQL Server};server=.;UID=sa;PWD=;database=mydb"
[其他解释]
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