string Sqlstr="Update PE_User set SpareEmail='" + SpareEmail.Text + "',Homepage='" + Homepage.Text + "',QQ='" + QQ.Text + "',ICQ='" + ICQ.Text + "',MSN='" + MSN.Text + "',Yahoo='" + Yahoo.Text + "',UC='" + UC.Text + "',Aim='" + Aim.Text + "',OfficePhone='" + OfficePhone.Text + "',HomePhone='" + HomePhone.Text + "',Fax='" + Fax.Text + "',Mobile='" + Mobile.Text + "',Country='" + Country.Text + "',Province='" + Province.Text + "',City='" + City.Text + "',Address=='" + Address.Text + "',ZipCode='" + ZipCode.Text + "',TrueName='" + TrueName.Text + "',Birthday='" + Birthday.Text + "',IDCard='" + IDCard.Text + "',Vocation='" + Vocation.Text + "',Company='" + Company.Text + "',Department='" + Department.Text + "',PosTitle='" + PosTitle.Text + "',Marriage='" + rBtListMarriage.SelectedItem.Value + "',Income='" + Income.Text + "',UserFace='" + UserFace.Text + "',FaceWidth='" + FaceWidth.Text + "',FaceHeight='" + FaceHeight.Text + "',Sign='" + Sign.Text + "',Privacy='" + rBtPrivacy.SelectedItem.Value + "' where UserName='" + Session["UserName"] + "'";
SqlCommand mycommand=new SqlCommand(Sqlstr,con);
con.Open();
mycommand.ExecuteNonQuery();
con.Close();错在哪里???
贴上错误信息:第 1 行: '=' 附近有语法错误。 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.SqlClient.SqlException: 第 1 行: '=' 附近有语法错误。源错误: 
行 251: SqlCommand mycommand=new SqlCommand(Sqlstr,con);
行 252: con.Open();
行 253: mycommand.ExecuteNonQuery();
行 254: con.Close();
行 255: }
 源文件: d:\web\lzt7\admin\user_login.aspx.cs    行: 253 堆栈跟踪: 
[SqlException: 第 1 行: '=' 附近有语法错误。]
   System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   lzt7.Admin.User_Login.btnFinish_Click(Object sender, EventArgs e) in d:\web\lzt7\admin\user_login.aspx.cs:253
   System.Web.UI.WebControls.Button.OnClick(EventArgs e)
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
   System.Web.UI.Page.ProcessRequestMain() 

解决方案 »

  1.   

    "Address=="  是不是这里多了个 =
      

  2.   

    楼主使用单步调试,在string Sqlstr前面设置一个断点,运行,在断点的地方程序会停止,按F10,
    运行到下一句,选中Sqlstr,按CTRL+ALT+Q,将会出现一个框,里面是你生成好的SQL语句,把SQL语句拷贝到查询分析器里面,去掉前后的"",执行语句,你会发现你的错误在什么地方
      

  3.   

    首先想问问你数据库中所有字段类型是不是都是字符串型,另外推荐一个方法可以调试,
    作一个调试断点,然后跟踪到该SQL语句,观察Sqlstr得值(可以将该值拷贝出来,放在记事本中看看),或者拷贝到SQL Server中的SQL执行功能中,看看到底是哪儿得毛病!