I need to check & capture user login details, and store it under Session to carry forward to next page. But i am getting this error, DataTable does not have definition for "Getvalue" at Session["idname"]= dt.GetValue(0).ToString();
.
The code i used,
con.Open();
SqlCommand cmd = new SqlCommand("select * from LoginDB where (EmpCode COLLATE Latin1_General_CS_AS = @EmpCode) and (Password COLLATE Latin1_General_CS_AS =@Password)", con);
cmd.Parameters.AddWithValue("@EmpCode", txtLogin.Text.Trim());
cmd.Parameters.AddWithValue("@Password", txtPwd.Text.Trim());
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
Session["idname"]= dt.GetValue(0).ToString();
ClientScript.RegisterStartupScript(Page.GetType(), "validation", "<script language='javascript'>alert('" + "Login Success!" + "')</script>");
Session["identity"] = txtLogin.Text;
Response.Redirect("Mainpage.aspx", false);
}
else
{
txtLogin.Text = "";
ShowMessage("UserId / Password is Not Correct!");
}
con.Close();