DonnaF Posted August 27, 2003 Posted August 27, 2003 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 I'm never hitting the Catch statement, no matter if the signon/password is valid or not. Thanks, Donna Quote
LostProgrammer Posted August 27, 2003 Posted August 27, 2003 There isn't 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. Quote
kleptos Posted August 27, 2003 Posted August 27, 2003 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: if(datareader.HasRows) { // User Exists } else { // No User Exists } This may help you out, i hope it helps even a little.firstexample.zip Quote ..::[ kleptos ]::..
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.