0
Dim cmd As OleDbCommand = New OleDbCommand("SELECT username,password FROM tblUsers where username=? and password=?", conn)
        Dim usernameParam As New OleDbParameter("@username", Me.txtUsername.Text)
        Dim passwordParam As New OleDbParameter("@password", Me.txtPass.Text)

        cmd.Parameters.Add(usernameParam)
        cmd.Parameters.Add(passwordParam)
        Try
            connectDatabase()
            Dim read As OleDbDataReader = cmd.ExecuteReader()
            If read.HasRows Then
                read.Read()
                If txtUsername.Text = read.Item("username").ToString And txtPass.Text = read.Item("password").ToString Then
                    MsgBox("Login successful")
                    frmMenuAdmin.Show()
                    Me.Close()
                Else
                    MsgBox("Login unsuccessful, username and passwords are case sensitive")
                End If
            Else
                MsgBox("Login unsuccessful")
            End If
            read.Close()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        Finally
            DisconnectDatabase()

        End Try
Dim read As OleDbDataReader = cmd.ExecuteReader()

< < < error here saying No value given for the one or required parameters

pls help

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by poojavb
0
Dim cmd As OleDbCommand = New OleDbCommand("SELECT username,password FROM tblUsers where username=? and password=?", conn)
        Dim usernameParam As New OleDbParameter("@username", Me.txtUsername.Text)
        Dim passwordParam As New OleDbParameter("@password", Me.txtPass.Text)

        cmd.Parameters.Add(usernameParam)
        cmd.Parameters.Add(passwordParam)
        Try
            connectDatabase()
            Dim read As OleDbDataReader = cmd.ExecuteReader()
            If read.HasRows Then
                read.Read()
                If txtUsername.Text = read.Item("username").ToString And txtPass.Text = read.Item("password").ToString Then
                    MsgBox("Login successful")
                    frmMenuAdmin.Show()
                    Me.Close()
                Else
                    MsgBox("Login unsuccessful, username and passwords are case sensitive")
                End If
            Else
                MsgBox("Login unsuccessful")
            End If
            read.Close()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        Finally
            DisconnectDatabase()

        End Try
Dim read As OleDbDataReader = cmd.ExecuteReader()

< < < error here saying No value given for the one or required parameters

pls help

Please check ur select query it has twice username=? written in it....

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.