visual studio 2010 连接数据库问题 着急
public static Boolean OperateData(string strsql)
{
try
{
SqlConnection conn = DBCon();
conn.Open();
SqlCommand cmd = new SqlCommand(strsql, conn);
cmd.ExecuteNonQuery();
conn.Close();
return true;
}
catch
{
return false;
}
}
//================登陆=========================================
public static bool CheckPerson(string sname, string sno)
{
string sql = "select count(*) from people where sname='" + sname + "' and sno='" + sno + "'";
OperateData(sql);
if (OperateData(sql))
{
return true;
}
else
{
return false;
}
//conn.Close();
}
这是一个baseclass.cs文件里面的代码
protected void Button2_Click(object sender, EventArgs e)
{
if (TextName.Text == "" || TextPwd.Text == "")
{
Response.Write("<script>alert('请出入用户名或密码!')</script>");
}
else
{
if (Baseclass.CheckPerson(TextName.Text.Trim(), TextPwd.Text.Trim()))
{
Session["sname"] = TextName.Text.Trim();
Response.Redirect("Default2.aspx");
}
else
{
Response.Write("<script>alert('用户名或密码错误!');location='Default.aspx'</script>");
}
}
}
这是页面.aspx.cs文件按钮事件
我现在不管用什么账户和密码都可以登录 数据库不管用了 怎么改啊 要用catch catch写的