VB 连接ACCESS时候出错 急!!!

来源:百度知道 编辑:UC知道 时间:2024/07/03 07:00:09
Public con As ADODB.Connection
Public rs As ADODB.Recordset
Dim Worker_number As Integer
Public str As String
Public summoney As Integer
Public usercount As Integer
Public u As String
Public a As Integer

Public Sub Load()
If Form2.Text1.Text = "999999" And Form2.Text2.Text = "1234" Then
Unload Form2
Form4.Show
Exit Sub
End If
Set con = New ADODB.Connection
str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\TSL.mdb;Persist Security Info=False"

con.Open str
u = Form2.Text1.Text
v = Form2.Text2.Text
str = "select * from Information where Worker_no =" & u & "and Password=" & v & " "
Set rs = New ADODB.Recordset
rs.Open str, con, adOpenDynamic, adLockPessimistic
If rs.EOF Then
If Count < 2 Then
Count = Count + 1
MsgBox "Worker number or passoword is

首先我想知道你有没有引用Microsoft ActiveX Data Objects 2.x Library
没有的话就先在“工程”-“引用”里找到。上面哪个2.X是版本号,我这里是2.8,不知道你那里是多少!

首先ADO的RECORDSOURCE要有效
然后绑定之后,窗体加载时要刷新数据
如下:
Adodc1.Refresh
如果你这句话没写,肯定没反应,还有如果在这句话上出错,则说明前面的RECORDSET有问题.自己试一下吧

你引用ADO了吗?