OLEDB问题
产生如下错误:
实时错误:‘2147217887(80040e21)' :
多步OLE DB 操作产生错误。如果可能,请检查每个OLE DB状态值。没有工作被完成
出错代码:
Private Sub Chk()
Rec Rs, "select * from code Where id=" & ID
If Not (Rs.EOF And Rs.BOF) Then
Text1.Text = Rs(2) ’报这里出错
Text2.Text = Rs(1)
Text3.Text = Rs(0)
Text4.Text = Rs(4)
Rec li, "select * from [type]"
Combo1.Clear
While Not li.EOF
Combo1.AddItem li(0)
li.MoveNext
Wend
Combo1.Text = Rs(3)
Combo2.Text = Rs(5)
Else
MsgBox "没有次记录!", vbOKOnly, "记录未找到"
End If
End Sub
连接代码:
"Provider=SQLOLEDB.1;Persist Security Info=False;Server=10.1.1.190;UID=sa;PWD=www.zhi.net;database=code;"
上面代码用到的自定义函数 Rec ‘生产记录集
Public Function Rec(Rs, SQL As String)
On Error Resume Next
Set Rs = CreateObject("ADODB.Recordset")
Rs.ActiveConnection = Conn
Rs.Source = SQL
Rs.CursorLocation = 1
Rs.CursorType = 3
Rs.LockType = 1
Rs.Open
If Err.Number > 0 Then
T = MsgBox("请检查数据库连接是否正确!" & Chr(10) & "SQL语句:" & Chr(10) & SQL, vbOKOnly, "数据库创建失败!")
Dialog.Show
End If
End Function