I have 2 tables:
IDM_IDEA_USERS
USER_ID
PASSWORD
SAP_ID
IDM_IDEA_AUTHORIZED_USERS
SAP_ID
I need to retrieve information from table IDM_IDEA_USERS column name USER_ID and PASSWORD. I also need to verify that only SAP_ID from IDM_IDEA_USERS table is the same as SAP_ID from IDM_IDEA_AUTHORIZED_USERS. Only the users from IDM_IDEA_AUTHORIZED_USERS can login.
This are my codings.
Dim conn As New OleDbConnection(My.Settings.ConnectionString)
Try
conn.Open()
Dim cmd As New OleDbCommand("Select Distinct * From IDM_IDEA_USERS and IDM_IDEA_AUTHORIZED_USERS Where IDM_IDEA_USERS.USER_ID=?, IDM_IDEA_USERS.PASSWORD=? and IDM_IDEA_USERS.SAP_ID = IDM_IDEA_AUTHORIZED_USERS.SAP_ID")
cmd.Parameters.Add("@p1", OleDbType.VarChar, 20)
cmd.Parameters("@p1").Value = Me.txtUser.Text.ToUpper
cmd.Parameters.Add("@p2", OleDbType.VarChar, 20)
cmd.Parameters("@p2").Value = Me.txtPass.Text
Dim dr As OleDbDataReader
dr = cmd.ExecuteReader
If dr.HasRows = True Then
frmTrackIDEA.Show()
Else
MsgBox("Invalid login!!Please check your username or password!", MsgBoxStyle.Exclamation, "INVALID")
End If
Catch ex As Exception
MsgBox(ex.Message)
Finally
conn.Close()
'Me.Hide()
End Try
after executing this, i got this error message:
ExecuteReader: Connection property has not been initialized.
How do i solve this?
I really hope u guys can help me.
Thanks