Visual Studio .NET - i want to create a window form which have a user id and password. checked by sql database

Asked By Manish Arya on 16-Aug-13 03:18 AM
Dear All,
i want to create a window form which have a user id and password. checked by sql database without using of dataset and dataadapter. With the use of datareader, how it is possible pls give me a example code.
Danasegarane Arunachalam replied to Manish Arya on 16-Aug-13 05:45 AM
Is there any specific purpose you want to avoid dataset?

Here is the code using Datareader

static void HasRows(SqlConnection connection)
{
using (connection)
{
SqlCommand command = new SqlCommand(
String.Format("Select * from user_table where username ={0} and password={};",UserName.Text, Passsword.Text),
connection);
connection.Open();
 
SqlDataReader reader = command.ExecuteReader();
 
if (reader.HasRows)
{
 // User found
}
else
{
Console.WriteLine("No User Found.");
}
reader.Close();
}
}