HELP on OLE Database Execution

brucelim80

Active member
Joined
Apr 20, 2006
Messages
35
Programming Experience
Beginner
confused:

Hi All,

Can anyone help me on this? i am a newbie

I have an access database and i will like to execute an sql statement to search for the password of the username.

For example i got a username call bruce lim8 to search but it was not found on the database.


How do i write a code to search for the database and prompt the user if the username is not found in the database.

I have written a code below but it will leave blank if the record is not found.

Can anyone help me?
THANK YOU











Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myData As New DataSet()
Dim myConnect As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\136.121.2.1\its helpdesk\CALLTRACK\ecall.mdb;")
myConnect.Open()
Dim strSelect As New OleDbCommand("SELECT * FROM useradmDB WHERE username='bruce lim7'", myConnect)
Dim reader As OleDbDataReader = strSelect.ExecuteReader


Do While reader.Read()


usrpswd.Text = reader.Item("password").ToString

Loop

End Sub
End Class
 
This is very simple after the loop insert the following statement

If usrname.text = "" Then
MessageBox.Show("The username could not be found in the database")
End if

There are a few others ways you can check this. But it is safe to assume that if the password is not filled in after that loop that it was not found in the database. Or there is something wrong with your SQL. But just show a messagebox if that text box is blank after it has tried to look for it.
 
Back
Top