Re: Unable to merge 2 mySQL Databases using OdbcDataAdapter.Update



Den,

Are you sure that the keys are equal. (And the table name, otherwise there
is just a new table added to the dataset).

I have here a very simple sample in VB about the merge. I am sure that you
as MCP can read it.

http://www.windowsformsdatagridhelp.com/default.aspx?ID=edb1409d-5394-468f-a63f-de3a5d92b14a

I hope this helps,

Cor

"den 2005" <den2005@xxxxxxxxxxxxxxxxxxxxxxxxx> schreef in bericht
news:84E20495-9DE2-4C1C-8378-F4427DAE7F58@xxxxxxxxxxxxxxxx
> Hi Cor,
> I have tried setting the DataAdapter.AcceptChangesDuringFill to false
> and still there is no records added to target database table, there is no
> records in this table and from surce database table there is 12 records. I
> am
> currently using the very long approach which is using select to compare
> the
> databases records and inserting new records and deleting records all this
> hard-coded, it is very very long lines of codes. But if you guys have some
> very much shorter lines of codes that works with mySQL database Ver 4.1,
> please tell me. Thanks for reply.
>
> den2005
> --
> MCP Year 2005, Philippines
>
>
> "Cor Ligthert [MVP]" wrote:
>
>> Den,
>>
>> As I wrote are with the function you use all rowstate set to not changed,
>> what means that nothing will be done with it during the update. To merge
>> something and to add that to another table, you have to tell that it are
>> new
>> rows in a dataset. That you get by setting the acceptchangesduringfill to
>> false (default it is true), see for that my previous message.
>>
>> Cor
>>
>> "den 2005" <den2005@xxxxxxxxxxxxxxxxxxxxxxxxx> schreef in bericht
>> news:F0D432B7-BAF7-4CF7-8F08-8A2C38343289@xxxxxxxxxxxxxxxx
>> > Hi Cor,
>> >
>> > Thanks for reply. I used another function to return the Datatable.
>> >
>> > Code:
>> >
>> > DataTable dt = comp.GetclientTable();
>> >
>> > int iRes = comp.UpdateServerTable1(dt);
>> >
>> >
>> > Code:
>> >
>> > public DataTable GetClientTable()
>> > {
>> >
>> > . . .
>> >
>> > OdbcDataAdapter odAdapter = new
>> > OdbcDataAdapter(sqlTextServer,odServerConn);
>> >
>> > if (odServerConn.State == ConnectionState.Closed)
>> > {
>> > odServerConn.Open();
>> > }
>> >
>> > DataSet ds = new DataSet();
>> >
>> > odAdapter.Fill(ds,"CheckFault");
>> >
>> > dt = ds.Tables["CheckFault"];
>> >
>> > if (odServerConn.State == ConnectionState.Open)
>> > {
>> > odServerConn.Close();
>> > }
>> >
>> > ...
>> >
>> > return dt;
>> > }
>> >
>> >
>> > den2005
>> > --
>> > MCP Year 2005, Philippines
>> >
>> >
>> > "den 2005" wrote:
>> >
>> >> 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
>> >> changes 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
>> >>
>> >> --
>> >> MCP Year 2005, Philippines
>>
>>
>>


.



Relevant Pages

  • Re: Refresh DataSet - please Help Me :-(
    ... >And than to get more help it probably better to ask this in the newsgroup ... Firstly let me say I agree with Cor, the best approach to a problem ... the usual approach to refreshing a dataset is to have one ... Update the database with any changes made. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Syntax error (missing operator) when delete with Commandbuider
    ... I was already using AcceptChanges etc on the second copy database but not on ... Hawkmoth ... "Cor Ligthert" wrote: ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Access BETWEEN statement seems faulty in VB.NET
    ... Cor, ... are just running a local copy of an MS Access database and a VB.NET ... are completely non-technical so ease of setup is paramount. ... Siv ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Accessing Databases
    ... Thank you Cor for your help. ... Do I need a OleDbDataConnection, ... > With an access database that is the connection approach a good approach, ...
    (microsoft.public.dotnet.languages.vb)
  • RE: Create table rights
    ... DB_DDLADMIN rights to the database. ... "Jose G. de Jesus Jr MCP, ... > Jose de Jesus Jr. ...
    (microsoft.public.sqlserver.security)