Dennis S

Dennis S

  • NA
  • 102
  • 2k

Updating server database with data from client database using DataSet.Merge and DataAdapter.Update

Sep 30 2005 1:48 AM

Hi Everybody,
   I am Updating server database with data from client database, I am using mySQL Ver 4.1, I am
unable to do that. What should I do to change the codes to make it work? I have also another
method that do the opposite data from server updates the database on client side. I need help.
There is no change in records of target database. I have saw some topics here at this forum.
The problem is Connection to server database is ok, but when "odAdapter.Update(ds,"<tablename>");" executes it returns value of 0 and on chnages made to server database, it should have 12 rows. Advanced Thanks.


Code:

public int UpdateServerTable1(DataTable dtObj)
{
   DataSet ds = new DataSet();
   int iRes = 0;
   try
   {   
 this.sqlTextServer = "Select * From <tablename>";

 OdbcDataAdapter odAdapter = new OdbcDataAdapter(this.sqlTextServer,this.odServerConn );

 odAdapter.Fill(ds,"<tablename>");

 ds.Merge(dtObj,true,MissingSchemaAction.Ignore);

 OdbcCommandBuilder cmdBuild = new OdbcCommandBuilder(odAdapter);

 iRes = odAdapter.Update(ds,"<tablename>");
 
   }
   catch (Exception ex)
   {
 ds.RejectChanges();
 
   }
   return iRes;
}

 


Regards,
denpsia


Answers (1)