VB6.0连接SQL Server2008 实时错误3709 请求的操作需要OLE DB会话对象,而当前的提供的程序不支持此对象

图片说明
图片说明

Public SqlConn As New ADODB.Connection
Public SqlRs As New ADODB.Recordset
Public SqlCmd As New ADODB.Command
Public Function DBConnect(strtype As String) As Boolean
Dim ConnStr As String
If SqlConn.State <> adSrareOpen Then
If strtype = "U" Then
SqlConn.Open ("FILE Name = " & App.Path & "\dbconn.udl")
Else
ConnStr = "Provider = SQLOLLEDB.1;Data Source = LAPTOP-ND06FMEL;User ID = sa;" & "Password = 12345678;Initial Catalog = StudentDB"
     SqlConn.Open (ConnStr)
End If
End If
  SqlCmd.ActiveConnection = SqlConn
DBConnect = True
End Function
Public Function ExecSQL(ByVal sql As String) As ADODB.Recordset
If SqlConn.State <> adStateOpen Then
DBConnect ("U")
End If
SqlCmd.CommandText = sql
Set ExecSQL = SqlCmd.Execute
End Function

1个回答

看下你前面SqlConn那两个条件不满足的情况下,是不是根本没有Open

weixin_43930678
宇霸霸 好像是SQL Conn 没有Open dbconn.udl 这个怎么写啊?
8 个月之前 回复
weixin_43930678
宇霸霸 额。。具体弄?
8 个月之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐