通过datagridview更新数据库,我用dataadapter的update()方法但是出错误,各位高手请帮个忙。

解决方案 »

  1.   

    有主键,说的是需要有效的update command
      

  2.   

    加上
    SqlDataAdapter sda = new SqlDataAdapter(你自己写);
    SqlCommandBuilder scb = nwe SqlCommandBuilder(sda);
    sda.Update();
    这样做
      

  3.   

    需要用sqldataadapter生成相关的update command!
      

  4.   

    没有生成相关命令.采用4楼的方法.SqlDataAdapter sda;
    ……
    SqlCommandBuilder scb = nwe SqlCommandBuilder(sda); 
    sda.Update(); 
      

  5.   

    有出现这样的异常:对于不返回任何键列信息的 SelectCommand,不支持 UpdateCommand 的动态 SQL 生成。
      

  6.   

    你是不是用了LEFT join ,就不行了,不支持多表生成动态SQL。
    另外,要这样
    SqlDataAdapter sda;
    sda =new SqlDataAdapter(conn,"select * from talbe ");
    SqlCommandBuilder scb = nwe SqlCommandBuilder(sda); //---保存时
    sda.Update();