Hi all,
I am developing an app where user logins then he is asked by system wether he wants to create new user?if yes he is allowed to do so. till this is all OK.
But when this new user tries to login to app, it fails. I checked everything and I find that the if(condition) then in below code always fails and control is directed to else and stuff in else block gets executed i.e. MessageBox showing NOT A VAILID USER
plz check the code given below and help me solving this problem...
plz help
Code is executed as user clicks on OK_button
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ok_btn.Click
'first check if username and password fields are empty
If (username.Text = "") Then
Label5.Visible = True 'show some msg
ElseIf (pswd.Text = "") Then ' check for password field is empty?
Label6.Visible = True 'show some msg
Else
Try
Label5.Visible = False
Label6.Visible = False
Dim con As OleDbConnection = New OleDbConnection(" provider=microsoft.jet.oledb.4.0;" & "data source=C:\Documents and Settings\AMEYA\My Documents\db2.mdb;")
Dim cmd As OleDbCommand = con.CreateCommand()
con.Open()
cmd.CommandType = CommandType.Text
cmd.CommandText = "select * from adminuser ;"
Dim dr As OleDbDataReader = cmd.ExecuteReader()
'advance the reader by one
dr.Read()
Dim temp As String = dr.GetString(0)
Dim temp1 As String = dr.GetString(1)
If (temp = username.Text And temp1 = pswd.Text) Then
'username and pswd are names of textboxes
Label1.Visible = True
ys_radiobtn.Visible = True
no_radio_btn.Visible = True
Else
MessageBox.Show("NOT a valid user", "WARNING")
username.Text = ""
pswd.Text = ""
End If
cmd.Dispose()
con.Close()
Catch ex As Exception
End Try
End If
End Sub