Consider the following example:
Suppose i have table tbleUserAuthentication, and two columns in this table i.e, Username and Password.
Following piece of code will help you to check information entered in Textbox against SQL Server.
SqlConnection con = new SqlConnection("Your Connection Here");
SqlCommand cmd_retrvefrmDB = new SqlCommand("select * from tbleUserAuthentication where username=@u and Password=@p",con);
cmd_retrvefrmDB.Parameters.AddWithValue("@u",Your_UserName_TextBox.Text);
cmd_retrvefrmDB.Parameters.AddWithValue("@p",Your_UserPassword_TextBox.Text);
con.Open();
SqlDataReader dr = cmd_retrvefrmDB.ExecuteReader();
if (dr.Read())
{
MessageBox.Show("User Logined. . .")
}
else
{
MessageBox.Show("Invalid Username and Password. . .")
}