0

我收到一条错误消息,指出我的代码片段中的表达式中的数据不匹配:

    [...]
    If Validate_User() Then
        strUser = Trim(Me.txtIDNumber.Text).ToLower
        Dim frm As New main
        Me.Hide()
        frm.ShowDialog()
    Else
        MsgBox("Incorrect IDNumber/Password")
    End If
    me1 = txtIDNumber.Text.ToString
    'txtIDNumber.Text = ""
    txtPassword.Text = ""
End Sub

Function Validate_User()
    Dim con As New OleDbConnection
    Dim cmd As New OleDbCommand
    Dim dr As OleDbDataReader
    Dim bValid As Boolean = False

    Try

        con = New OleDbConnection(Get_Constring)
        con.Open()
        cmd.Connection = con
        cmd.CommandType = CommandType.Text
        ' cmd.CommandText = "select ID from students_records where IDNumber = '" & Me.txtIDNumber.Text & "' and MiddleName = '" & Me.txtPassword.Text & "'"
        cmd.CommandText = "select IDNumber from students_records where IDNumber = '" & Me.txtIDNumber.Text & "' and MiddleName = '" & Me.txtPassword.Text & "'"

        dr = cmd.ExecuteReader
        If dr.HasRows Then
            bValid = True
        End If

    Catch ex As Exception
        MsgBox(ErrorToString)
    Finally
        con.Close()
    End Try

    Return bValid
End Function
4

0 回答 0