这是参考我之前的问题:
我使用以下代码来执行我的查询。但是我在存储命令中的值然后使用该结果比较值时遇到问题。
这是我的代码:
SqlDataReader sdrDatanew = null;
string strnew;
string connectionString = WebConfigurationManager.ConnectionStrings["Gen_LicConnectionString"].ConnectionString;
SqlConnection connew = new SqlConnection(connectionString);
connew.Open();
strnew = "select User_Type from User_Details where User_Type='" + ddlUserSel.SelectedItem.Value + "' AND LoginID = '" + txtUserName.Text + "' AND Password = '" + txtPassword.Text + "'";
SqlCommand sqlCommnew = new SqlCommand(strnew, connew);
sdrDatanew = sqlCommnew.ExecuteReader();
if (sdrDatanew.HasRows)
{
if (sdrDatanew.Read())
{
//Here I want to store the result from the sqlcommand in a variable
}
}
switch (//Here I want to use the variable in a switch case) //<---
{
case 0:
Response.Redirect("Lic_Gen.aspx");
break;
case 1:
Response.Redirect("Cust_Page.aspx");
break;
}
connew.Close();