Iam问问题以前有2个相同的帖子但是没有一个用于我的代码,所以我在这里提出问题
Function getJobHistory1(ByVal ServerName)
Set cmdsrvlist1 = CreateObject("ADODB.Command")
Set cnsrvlist1 = CreateObject("ADODB.Connection")
Set rssrvlist1 = CreateObject("ADODB.Recordset")
MsgBox(ServerName)
'tried the following; not working
'cnsrvlist.Open "Provider=SQLOLEDB.1;Data Source=Av-RISCDCSQL821\SQL821;Integrated Security=SSPI"
'tried this as well; not working
cnsrvlist1.ConnectionString = "Provider=SQLNCLI10.1;Data Source=" & ServerName & ";Integrated Security=SSPI"
MsgBox(cnsrvlist1)
cnsrvlist1.Open
cmdsrvlist1.ActiveConnection = cnsrvlist1
cn.Close
End Function
收到以下错误: