ASP.NET语法错误。。。。求助
string conStr;
conStr = "Data Source=WIN-58FJ35C0IMC;Initial Catalog=trainbook; Integrated Security=True";
SqlConnection con = new SqlConnection(conStr);
//打开数据库
con.Open();
string sqlsele="select count(*) from 用户 where 用户ID=@name and 密码=@passw";
//创建SqlCommand对象
SqlCommand mycom = new SqlCommand(sqlsele , con);
//使用Parameter的add方法添加参数类型
mycom.Parameters.Add(new SqlParameter("name", SqlDbType.VarChar, 20));
mycom.Parameters.Add(new SqlParameter("passw", SqlDbType.VarChar, 50));
//设置Parameters的参数值
mycom.Parameters["name"].Value = TextBox1.Text;
//使用MD5加密将的用户输入的密码加密
string pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(TextBox2.Text.Trim(), "MD5");
mycom.Parameters["passw"].Value = pwd;
if (Convert.ToInt32(mycom.ExecuteScalar()) > 0)
{
Response .Write ("<script>alert('登录成功!')</script>");
//清空文本框
TextBox1.Text = TextBox2.Text = TextBox3.Text = "";
Response.Redirect ("~/shouye.aspx");
}
红色那句老报错:‘(’附近有语法错误,求高手帮忙看看。不胜感激
------解决方案--------------------C# code
string sqlsele="select count(*) from 用户 where [用户ID]='@name' and 密码='@passw'";
------解决方案--------------------
string sqlsele="select count(*)from 用户 where 用户ID=@name and 密码=@passw";
红色部分是中文括号,
改成英文的
string sqlsele="select count(*) from 用户 where 用户ID=@name and 密码=@passw";
mycom.Parameters.Add(new SqlParameter("@name", SqlDbType.VarChar, 20));
mycom.Parameters.Add(new SqlParameter("@passw", SqlDbType.VarChar, 50));