头晕了~~这是什么情况~~
我要掉用DBHELPER里的
/// <summary>
/// 返回第一行第一列(String类型),无参数
/// </summary>
/// <param name="sql"></param>
/// <returns></returns>
public static string ReturnStringScalar(string sql)
{
try
{
SqlCommand comm = new SqlCommand(sql, ConnectionString);
return comm.ExecuteScalar().ToString();
}
catch (Exception ex)
{
return null;
}
finally
{
ConnectionString.Close();
}
}这个方法
-----------------------------------------------------------------------------------------------------------
如果有1条记录那就跳转但是现在不管密码输入正确或者错误都是跳错误提示
protected void imgbt_login_Click(object sender, ImageClickEventArgs e)
{
string sql = " select count(1) from [login] where uid=@uid and pwd=@pwd and groupname=@groupname";
SqlParameter[] sqlparameters ={
new SqlParameter("@uid",txt_name.Text),
new SqlParameter("@pwd",txt_pwd.Text),
new SqlParameter("@groupname",DropDownList1.Text)
};
int num = DBHelPer.GetScalar(sql);
if (txt_name.Text != "" && txt_pwd.Text != "")
{
if (num > 0)
{
Session["name"] = txt_name.Text.Trim();
Response.Redirect("~/个人/adminindex.aspx");
}
else
{
Response.Write("<script language = javascript>alert('用户名或密码错误!');</script>");
return;
}
}
else
{
Response.Write("<script language = javascript>alert('用户名或密码不能为空!');</script>");
return;
}
菜鸟问题求解决