我在vb6中使用这个简单的编码来连接到Access数据库,但每次编译此代码时都会显示错误:
参数不是可选的
并突出显示Private Sub Loginbtn_Click()
和txtUsrName
。
Private Sub Command1_Click()
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=E:\Ash\New folder (2)\login form.mdb;" _
& "Persist Security Info=False"
conn.Open
Dim rs As New ADODB.Recordset
rs.Open "SELECT * FROM table1 WHERE username = '" & txtUsrName & "'", conn, adOpenStatic, adLockReadOnly
If rs.RecordCount <> 0 Then
If txtPwd = rs!Password Then
MsgBox "Username and Password Succesful!"
'Remove msgbox above then call a form to be load if login is succesful!
Call MDIForm1.Show
Else
MsgBox "Invalid Password, try again!", , "Login"
End If
Else
MsgBox "Invalid Login, try again!", , "Login"
End If
rs.Close
Set rs = Nothing
End Sub
答案 0 :(得分:0)
我认为您只需要更改MsgBox
命令:
MsgBox "Invalid Password, try again!", , "Login"
到
MsgBox "Invalid Password, try again!", "Login"