请求的操作需要OLE DB会话对象,当前提供程序不支持该对象

时间:2017-01-19 08:07:12

标签: sql-server vbscript

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

收到以下错误:

Requested operation requires an OLE DB Session object, which is not supported by the current provider.

0 个答案:

没有答案