Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted
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.
Posted

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

..::[ kleptos ]::..

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...