Am using Asp.net, C# to work with the following code. When I connect to the server (MS SQL Server), But for now I have problem with the condition in if-statement that not executed, and only else-statement always (in all cases) executed. In details, ID number (which will generated from HSDB database) must match with the BID Session variable, How to fix that?
Can any one help me with good condition that I can work with it correctly.
protected void Button1_Click(object sender, EventArgs e)
{
Session["BID"] = Ben_id.Text;
var pid = Session["BID"];
SqlConnection conn1 = new SqlConnection(ConfigurationManager.ConnectionStrings["HSDBConnectionString"].ConnectionString);
SqlCommand cmd1 = new SqlCommand("select * from P where ID=@id", conn1);
conn1.Open();
if (pid == cmd1 )
{
Response.Redirect("infoPage.aspx");
}
else
{
Response.Redirect("Register.aspx");
}
conn1.Close();
}
Aucun commentaire:
Enregistrer un commentaire