You can follow these steps:
1. using System.Data.SqlClient;
2.
protected void Button1_Click(object sender, EventArgs e)
{
string str = "Data Source=ABC-PC\\SQLEXPRESS;Initial Catalog=demodb;Integrated Security=True";
SqlConnection conn = new SqlConnection(str);
conn.Open();
string adminId = txtadminId.Text;
string password = txtpassword.Text;
string query = "SELECT admin_id, password FROM users WHERE id=@adminId
and password=@password";
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = query;
cmd.Parameters.AddWithValue("@admin_id", adminId);
cmd.Parameters.AddWithValue("@password", password);
SqlDataReader dr = cmd.ExecuteReader();
hope this helps:)
for more info comment here!!