vb 连接access数据库时出现的问题,急急急!!!!!!!!!!!!!!!!!!!!!
Private Sub MDIForm_Initialize()Dim mpath As String
mpath = App.Path //进入access 数据库存放的目录
If Right(mpath, 1) <> "\" Then mpath = mpath + "\"
Data1.DatabaseName = mpath + "vbdata.mdb" //使用data控件
Data1.RecordSource = "access"
End Sub
Private Sub Command1_Click()
If Data1.Recordset.EOF Then Data1.Recordset.MoveFirst
do while Data1.Recordset.EOF
If Data1.Recordset.EOF Then //运行时此处出错
MsgBox "no find! ", vbYesNo, "Unfind"
Load MDIForm1
MDIForm1.Show
Text1(0) = "": Text1(1) = "" //文本框
exit do
Else
if Text1(0) = Data1.Recordset.fields("姓名") and Text1(1) = Data1.Recordset.fields("学号") then
Load Form1
Form1.Show
MDIForm1.hide
else
Data1.Recordset.MoveNext
End If
end if
loop
End Sub --------------------编程问答-------------------- 改成如下就行了:
Data1.RecordSource = "access" '首先确定你有名为access这个表,否则设为表名或查询语句
Data1.Refresh '主要是加这句
End Sub
Private Sub Command1_Click()
'Data1.refresh
If Data1.Recordset.EOF Then Data1.Recordset.Move
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''另外
if Text1(0) = Data1.Recordset.fields("姓名") and Text1(1) = Data1.Recordset.fields("学号") then
Load Form1
Form1.Show
MDIForm1.hide
exit do '这里可能死循环,应退出
else
Data1.Recordset.MoveNext
End If
补充:.NET技术 , VB.NET