Try like this
protected void btnLogin_Click(object sender, EventArgs e)
{
DataSet ds = new DataSet();
DataTable dt = new DataTable();
SqlDataAdapter adp = new SqlDataAdapter();
using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conStr"].ConnectionString))
{
SqlCommand cmd = new SqlCommand("Login_Check_Sp", conn);
cmd.Parameters.AddWithValue("@username", txtUserName.Text.Trim());
cmd.Parameters.AddWithValue("@pwd", txtPwd.Text.Trim());
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
da.Fill(ds);
dt = ds.Tables[0];
if (dt.Rows.Count > 0)
{
lblStatus.Text = "Login Successfull";
}
else
{
lblStatus.Text = "Wrong Username/Password";
}
}
}
Try the above code and still if you have error .
Debug aand using break point check where you get the error.
There might be many reason as connection might not established.
here is few link which explains how to use break point in visual studio.
http://www.tutorialspoint.com/asp.net/asp.net_debugging.htm[
^]
https://www.youtube.com/watch?v=k1EQndVmlOc[
^]