我不知道if判断怎么写,我的管理员字段是type,想判断type= 管理员就可以实现管理员登录,否则用户登录,求求大佬!
string sql = "select * from login where name ='" + TextBox1.Text.Trim() + "' and pwd = '" + TextBox2.Text.Trim() + "'";
string connstr = ConfigurationManager.AppSettings["constr"];
SqlConnection conn = new SqlConnection(connstr);
SqlCommand cmd = conn.CreateCommand();
cmd.CommandText = sql;
try
{
conn.Open();
SqlDataReader r = cmd.ExecuteReader();
if (r.Read () )
{
Response.Redirect("http://localhost:56515/admin/index.html");
}
else
{
Response.Redirect("http://localhost:56515/user/index.html");
}
}