Hi,
Doing a project in vb.net whereby i have different levels of users accessing the system, i have established a connection with the database where all the info will be stored but got stuck when trying to retrieve the data.. i am using and oledb connection
At the log-in form when user types there details in (staffid) & (password), and click the button, these details are verified to allow access or not...
Here is what i have coded so far
Imports MySql.Data.MySqlClient
Imports System.Data.OleDb
--------------------
Public Class StaffM
Dim cN As OleDbConnection
Dim myDataReader As OleDbDataReader
Dim myOleDbCommand As OleDbCommand
Dim username As String, password As String
------------------
Private Sub loginS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles loginS.Click
cN = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\LVuserdb.accdb;Jet OLEDB:Database Password=1")
myOleDbCommand = New OleDbCommand("SELECT staffid,password FROM Staff", cN)
username = Me.staffid.Text
password = Me.staffpass.Text
' Open a connection.
cN.Open()
' Look up the user name/password.
myDataReader = myOleDbCommand.ExecuteReader()
' See if there is a match.
Do While (myDataReader.Read())
If (myDataReader.IsDBNull(4)) Then
' If there is no match.
' Do not allow the login.
Me.Hide()
MsgBox("Invalid user name/password")
Else
' There is a match.
' Display the program's main form.
Staffmenu.Show()
Me.Hide()
End If
Loop
' Close when finished reading.
myDataReader.Close()
' Closes the connection when done
cN.Close()
End Sub
---------------------------
My problem is
myDataReader = myOleDbCommand.ExecuteReader()
and im not too sure if the Do while and If statement bit is correct
Any help would be much appreciated.
Thanks