Step 1: go to WebConfig File and Write this Code:
enter code here
<connectionStrings>
<add name ="MyDbConn" ---> write same it is
connectionString="Server=SYED\SQLEXPRESS; database=Templete_2_DB;
Trusted_Connection=True" providerName="System.data.sqlclient"
/>
</connectionStrings>
code here
SYED\SQLEXPRESS; ---> this is your servername
Templete_2_DB; ----> this is your database name
step 2: Go to your page event and write code like this..
enter code here
SqlConnection con = new SqlConnection(
WebConfigurationManager.ConnectionStrings["MyDbConn"].ConnectionString);
SqlCommand cmd = new SqlCommand("select * from Accounts_Data where
UserName=@username and Password=@password", con);
cmd.Parameters.AddWithValue("@username", txt_username.Text);
cmd.Parameters.AddWithValue("@password", txt_userPassword.Text);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
if (dt.Rows.Count > 0)
{
Response.Redirect("Default.aspx");
}
code here
Go ahead... in this you will be guided
https://www.youtube.com/watch?v=Mo0ECWKVVDU