protected void Button2_Click(object sender, EventArgs e)
{
//string m_connStr = "Initial Catalog=NO1;Data Source=(local);User ID=sa;Password=123456";
SqlConnection con = new SqlConnection("server=(local);database=Salebooks;UID=sa;PWD=123456");
con.Open();
if (TextBox1.Text == "")
{
Response.Write("<script>alert('用户名不能为空!')</script>");
TextBox1.Focus();
}
else
if (TextBox2.Text == "")
{
Response.Write("<script>alert('密码不能为空!')</script>");
TextBox2.Focus();
}
string strSQL = "select * from user where userid='" + TextBox1.Text + "' AND password='" + TextBox2.Text + "'";
DataSet ds = new DataSet();
SqlDataAdapter sa = new SqlDataAdapter(strSQL,con);
sa.Fill(ds,"user");
con.Close();
if (ds.Tables[0].Rows.Count > 0)
{
Response.Redirect("register.aspx");
}
else
{
Response.Write("<script>alert('用户名或密码错误')</script>");
}
}
这是我的源码,但出现一下错误,求解!

这是我改网上的,想拿来学习一下,结果出错了。