Identify Record Not Found

DonnaF

Active member
Joined
Mar 20, 2003
Messages
30
I have an application where I am asking the user to enter a signon and password. Then the customer file is read to see if they are valid. I do not need to retrieve any of the data - just verify that the record is on the database table. A couple of questions - How did I determine if the no records were found, after doing the select (see the code below)? Do I need to fill a dataset, and compare the fields (signon and password) to what was passed to the select statement? How do I access the dataset fields to do the compare? The only experience I have is with datasets is filling datagrids.

DataAdapter1.SelectCommand.CommandText = _
"SELECT CustomerID, UserPassword FROM Customers " & _
"WHERE CustomerID = mcustID & UserPassword = mPassword"
Try
DataAdapter1.SelectCommand.ExecuteNonQuery()

Catch exceptionparameter As Exception
MessageBox.Show(exceptionparameter.Message)
End Try

Im never hitting the Catch statement, no matter if the signon/password is valid or not.

Thanks, Donna
 
There isnt an error or an exception being thrown. You are returning an empty dataset. Another way to try is using a datareader and then testing the rdr.Read condition. If it is false then there are no matching records.
 
Here is a small example i used a while back when learning ADO.NET programming. Its written in C#, but the basics are there. The part you may be interested in is this:
Code:
if(datareader.HasRows)
{
    // User Exists
}
else
{
    // No User Exists
}

This may help you out, i hope it helps even a little.
 

Attachments

Back
Top