string sqlstr ="update company user_city='"+user_city.Text+"',jianj='"+jianj.Text+"  where id='"+id+"'"; 这句Sql语句写错了.

解决方案 »

  1.   

    sqlstr ="update company set cname='"+cname.Text+"'.... where id='"+id+"'"; 谢谢高手的回复,我查检查过了,没写错,因为太多字段了,我删掉很多,拷上来贴贴的时候拷漏了。
      

  2.   

    提交之后显示的错误是这样的,我做的另一个修改页面也是用这种方法去做的可以修改成功,真搞不懂是怎么回事,是不是跟数据库设置有关呢?请大家帮帮我这个笨菜鸟了谢谢大家。Runtime Error 
    Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine. Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".
    <!-- Web.Config Configuration File --><configuration>
        <system.web>
            <customErrors mode="Off"/>
        </system.web>
    </configuration>
     Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.
    <!-- Web.Config Configuration File --><configuration>
        <system.web>
            <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
        </system.web>
    </configuration>
     
      

  3.   

    出现这个页面的原因是这个页面不是在服务器上运行的并且页面运行时出异常了如果是在服务器上运行的话,就会显示具体的异常了从楼主的代码,可以知道Page_Load方法有错,DataReader没有关闭
      dr=mycomm.ExecuteReader();
      if(dr.Read())
      {
      user_city.Text= dr["user_city"].ToString();
      jianj.Text = dr["jianj"].ToString();
     
      } 
      dr.Close();//用完之后,IDataReader必须关闭
       myconn.Close();
      

  4.   

    非常感谢xixigongzhu(夕夕公主),谢谢谢谢,我试试看~!~~~~~
      

  5.   

    唉,真是晕死,又出现新错误,我打印那句update的sql语句,各个字段都可以取到正确的值啊,各们大虾救救我,救救我这只初学的蠢猪,我不知道怎么解决啊,等着交差的。新错误如下————————————————————异常详细信息: System.Data.SqlClient.SqlException: 第 1 行: '5534' 附近有语法错误。源错误: 行 118
    行 116:
    行 117: myconn.Open();
    行 118: mycomm.ExecuteNonQuery();
    行 119: myconn.Close();
    行 120: Response.Write("<script language='JavaScript'>alert('操作已成功!');window.location.href='update.aspx';</"+"script>");
     源文件: c:\inetpub\wwwroot\company\update.aspx.cs    行: 118 堆栈跟踪: 
    [SqlException: 第 1 行: '5534' 附近有语法错误。]
       System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +180
       company.update.Button1_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\company\update.aspx.cs:118
       System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
       System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
       System.Web.UI.Page.ProcessRequestMain() +1277 
      

  6.   

    非常谢谢mqmmx(奔腾2000) !我试试看
      

  7.   

    先把跟踪的SQL语句拿到数据库下直接运行,如果不能执行,就是sql语句的错误,修改sql语句知道正确即可;你的那种错误一般来说就是sql语句没有写对,不要太相信自己的眼睛,还是实践比较正确。
      

  8.   

    来几个个messagebox,再来几个Throw我就不信你堵不着错误!
      

  9.   

    很明显是你的SQL语句有问题,你调试把SQL语句取出来,拿到数据库管理器里面执行试试看就知道了。
      

  10.   

    终于解决问题了,真的真的好谢谢你们哦,真的是sql语句的问题,太多字段了,我写少了两处的“'”符号:)初来CSDN社区,没积分,小小心意,每人一分