//建立SQL构造器
SqlCommandBuilder cb=new SqlCommandBuilder(da);
//添加主键信息
da.MissingSchemaAction=MissingSchemaAction.AddWithKey;

try
{
   //提交到数据库
                              da.Update(ds.Tables[0]);
}
catch(SqlException e)
{
throw e;
}

解决方案 »

  1.   

    对,不要以为AcceptChanges()是接受更改
      

  2.   

    The method //acessDS.AcceptChanges()  doesn't work
      

  3.   

    去掉了,也不管用!what's wrong with the code?
      

  4.   

    //这样改
    OleDbDataAdapter myDA=new OleDbDataAdapter("select * from hrmis_t_unit_base",Form1.connAccess );

    DataSet accessDS=new DataSet();
    myDA.Fill(accessDS,"unitBase");
    accessDS=dsSqlServer.Copy();

    //accessDS.AcceptChanges();

    //myDA.Update
    //建立SQL构造器
    SqlCommandBuilder cb=new SqlCommandBuilder(myDA);
    //添加主键信息
    myDA.MissingSchemaAction=MissingSchemaAction.AddWithKey;

    try
    {
       //提交到数据库
                                  myDA.Update(ds.Tables["unitBase"]);
    }
    catch(SqlException e)
    {
    throw e;
    }
      

  5.   

    应调用Update();提交修改至数据库;
      

  6.   

    it still doesn't work !
    :(
      

  7.   

    MessageBox.Show("同步服务器成功!");
    这句有提示出来吗!
      

  8.   

    你自己定义一个UpdateCommand看看,然后在Update的时候按照MSDN那样
    先myDA.update再用accessds.AcceptChanges()
      

  9.   

    UpdInfCmd.CommandText = "Update SubjectInclude set state = @state  where SubjectID = @SubjectID and InfoID = @InfoID";
    UpdInfCmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@State", System.Data.SqlDbType.TinyInt, 1, "State"));
    UpdInfCmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@SubjectID", System.Data.SqlDbType.Int, 4, "SubjectID"));
    UpdInfCmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@InfoID", System.Data.SqlDbType.Int, 4, "InfoID"));
    InfoAda.UpdateCommand = UpdInfCmd;
    ...
    ...
    InfoAda.Update(myds,"test");
    myds.AcceptChanges();