用户 sa 登陆失败
public partial class yanzheng : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string username = Request.Form["username"].ToString();
string userpassword = Request.Form.Get("userpassword").ToString();
SqlConnection con = new SqlConnection("server=.;database=text;uid=sa;pwd=fengqq6604;");
con.Open();
SqlCommand cmd = new SqlCommand("select count(*) from text where username ='" + username + "' and userpassword='" + userpassword + "'", con);
int count = Convert.ToInt32(cmd.ExecuteScalar());
if (count > 0)
{
Response.Redirect("main.aspx");
}
else
{
Response.Redirect("loginFail.htm");
}
}
}
代码如上
用的VS2005 数据库是用SA登陆的 密码什么都确定 执行到con.Open();出现异常
请问问题出在哪里 具体该如何解决?