1
Answer

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

Dennis S

Dennis S

19y
2k
1

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)