在VB中使用ADO与Access数据库 建立登录对话窗体:
 Access中建立数据库:testdb.mdb 表 user 属性 user_account,user_password 
 vb工程中代码如下:
Option Explicit
Dim result As IntegerPrivate Sub Command1_Click()
    If Text1.Text = "" Or Text2.Text = "" Then
        MsgBox "用户名/密码不能为空"
        Exit Sub
    End If
    
    result = UserValidate(Text1.Text, Text2.Text)
    
    If result = 0 Then
      
        Unload Me
    Else
        Select Case result
            Case 1:
                MsgBox "用户" & frmLogin.Text1 & "不存在"
            Case 2:
                MsgBox "用户" & frmLogin.Text1 & "密码错误"
            Case Else
                MsgBox "为知错误"
        End Select
    End If
End SubPrivate Sub Command2_Click()
    
    End
    
End SubFunction UserValidate(input_user As String, input_password As String) As Integer
    Dim rs As New ADODB.Recordset
    Dim sql As String
    Dim tmp_password As String
    Dim conn As New ADODB.Connection
    
    conn.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source= " & App.Path & "\testdb.mdb;persist security info=false"
    conn.Open
    rs.ActiveConnection = conn
    sql = "select user_account,user_password FROM user where user_account ='" & input_user & "'"
    Call rs.Open(sql, conn)
    
    If (rs.EOF) Then
        UserValidate = 1
        rs.Close
        conn.Close
        Exit Function
    End If
    
    tmp_password = rs("user_password")
    
    rs.Close
    conn.Close
    
    If StrComp(tmp_password, input_password) Then
        UserValidate = 2
        Exit Function
    End If
    
    UserValidate = 0
    
End FunctionPrivate Sub Form_Load()
    result = -1
         
End Sub
Private Sub form_unload(cancel As Integer)
    If (Not result) Then
        frmMain.Show
    End If
End Sub每次按F5调试,输入正确的用户名和密码总是返回错误信息:“Form 子句语法错误” 但我看不出哪错,到底错在哪呢?