sqlcom.ExecuteNonQuery(); ')' 附近有语法错误.
protectedvoidbtmcreate_Click(objectsender,ImageClickEventArgse){name=this.txtName.Tex...
protected void btmcreate_Click(object sender, ImageClickEventArgs e)
{
name = this.txtName.Text;
pass = this.txtPass1.Text;
string usrealname = this.txtRealname.Text;
string usidnum = this.txtIDnum.Text;
string usphone = this.txtPhone.Text;
string usemail = this.txtEmail.Text;
int usrole = 1;
string sqltest = "select * from [User] where username='" + this.txtName.Text + "'";
con.Open();
SqlCommand sqlcom = new SqlCommand(sqltest, con);
SqlDataReader read = sqlcom.ExecuteReader();//从表中逐条查询符合上面条件的数据
read.Read();
if (read.HasRows)//该值指示SqlDataReader是否包含一行或多行
{
if (this.txtName.Text.Trim() == read["username"].ToString().Trim())//判定是否为已注册的客户
{
Response.Write("<script language='javascript'>alert('该会员已经注册过');localtion='Register.aspx'</script>");
return;
}
}
string sqlstr = "insert into User(username,password,realname,idnumber,email,phone,role)values('" + name + "','" + pass + "','" + usrealname + "','" + usidnum + "','" + usemail + "','" + usphone + "','" + usrole + "',)";
sqloperate.DataCom(sqlstr);//DataCom:数据通信,即为数据的更新
con.Close();
Session["regName"] = txtName.Text.Trim();//由于session对象MName有时间上的限制(20分钟),若客户登录后20分钟不操作即自动退出,即保护客户的账号安全
Response.Redirect("SuccReg.aspx");//重定位至"SuccReg.aspx"
}
一直有sqlcom.ExecuteNonQuery(); ')' 附近有语法错误.这个报错,请问哪里写错了吗? 展开
{
name = this.txtName.Text;
pass = this.txtPass1.Text;
string usrealname = this.txtRealname.Text;
string usidnum = this.txtIDnum.Text;
string usphone = this.txtPhone.Text;
string usemail = this.txtEmail.Text;
int usrole = 1;
string sqltest = "select * from [User] where username='" + this.txtName.Text + "'";
con.Open();
SqlCommand sqlcom = new SqlCommand(sqltest, con);
SqlDataReader read = sqlcom.ExecuteReader();//从表中逐条查询符合上面条件的数据
read.Read();
if (read.HasRows)//该值指示SqlDataReader是否包含一行或多行
{
if (this.txtName.Text.Trim() == read["username"].ToString().Trim())//判定是否为已注册的客户
{
Response.Write("<script language='javascript'>alert('该会员已经注册过');localtion='Register.aspx'</script>");
return;
}
}
string sqlstr = "insert into User(username,password,realname,idnumber,email,phone,role)values('" + name + "','" + pass + "','" + usrealname + "','" + usidnum + "','" + usemail + "','" + usphone + "','" + usrole + "',)";
sqloperate.DataCom(sqlstr);//DataCom:数据通信,即为数据的更新
con.Close();
Session["regName"] = txtName.Text.Trim();//由于session对象MName有时间上的限制(20分钟),若客户登录后20分钟不操作即自动退出,即保护客户的账号安全
Response.Redirect("SuccReg.aspx");//重定位至"SuccReg.aspx"
}
一直有sqlcom.ExecuteNonQuery(); ')' 附近有语法错误.这个报错,请问哪里写错了吗? 展开
1个回答
Storm代理
2023-08-29 广告
2023-08-29 广告
"StormProxies是全球大数据IP资源服务商,其住宅代理网络由真实的家庭住宅IP组成,可为企业或个人提供满足各种场景的代理产品。点击免费测试(注册即送1G流量)StormProxies有哪些优势?1、IP+端口提取形式,不限带宽,I...
点击进入详情页
本回答由Storm代理提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询