Search code examples
sql-serverdatasetpassword-checker

DataSet querying like SQL table


Is there a way to query a DataSet like a SQL table? Eg. I want to check in DataSet if username matches password. I could use this code like this:

foreach (DataRow row in dataset.Tables[0].Rows)
{
   MessageBox.Show(row.ItemArray[1].ToString());
}

but I just want it to select row which have given username, not to iterate entire table.

Thanks.


Solution

  • You can use

     dataset.Tables[0].Select(....)
    

    http://msdn.microsoft.com/en-us/library/det4aw50.aspx

    But you shouldn't. In almost every circumstance, the SQL server will be quicker at finding the match.

    Also, you should hash your passwords