c#代码如下:
 protected void btn_submit_Click(object sender, EventArgs e)
    {
        string sql = "update tb_userInfo set{ username='"+tb_username.Text.Trim()+"',qq='"+tb_qq.Text.Trim()+"',tel='"+tb_tel.Text.Trim()+"',birthday='"+tb_birthday.Text.Trim()+"',age='"+tb_age.Text.Trim()+"',education='"+tb_education.Text.Trim()+"',job='"+tb_job.Text.Trim()+"',company='"+tb_company.Text.Trim()+"',playyears='"+tb_playyears.Text.Trim()+"',loveteam='"+tb_loveteam.Text.Trim()+"',lovestar='"+tb_lovestar.Text.Trim()+"' } where ID="+ Session["user"].ToString();        SqlConnection con = new SqlConnection(@"Data Source=yangbiao\sqlexpress;Initial Catalog=db_footballfans;Integrated Security=true");
        //sex='"+dpdlst_sex.Text+"',province='"+province.Text+"',city='"+city.Text+"',area='"+area.Text+"',
        SqlCommand com = new SqlCommand(sql,con);
        con.Open();
        com.ExecuteNonQuery();//此处提示‘{’附近有语法错误        con.Close();
    }

解决方案 »

  1.   

    行 126:        SqlCommand com = new SqlCommand(sql,con);
    行 127:        con.Open();
    行 128:        com.ExecuteNonQuery();行 129:        con.Close();
    行 130:    }
    我的update语句没错啊,检查了很多次没发现错误。其中数据库列中:age,playyears为int型,birthday为datetime型,其他都是varchar型。数据库连接没问题,就是更新到数据库时出错了
      

  2.   

    update tb_userInfo set{
    =>
    update tb_userInfo set
    } where ID=
    =>
     where ID=把大括号都去掉
      

  3.   

    这么强大的sql,调试时放到数据库中执行一下,错误一目了然
      

  4.   

    明显 sql语法错误啊去年大括号后  调试得到string sql 的值 放到SQL查询分析器中执行一下
      

  5.   

    汗!我是参考一本书上介绍sql update语句写的,居然误导我,真悲惨
      

  6.   

    其中数据库列中:age,playyears为int型
    ',age='"+tb_age.Text.Trim()+"'错啦
    正型的无需单引号
    改成age="+tb_age.Text.Trim()+"。。
    所有的数值型的变量都不能要单引号。
      

  7.   

    加{}在sql server可以运行,只是在.net中不能用