Re: Unable to merge 2 mySQL Databases using OdbcDataAdapter.Update
- From: "Cor Ligthert [MVP]" <notmyfirstname@xxxxxxxxx>
- Date: Fri, 7 Oct 2005 11:02:31 +0200
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
>>
>>
>>
.
- Follow-Ups:
- References:
- RE: Unable to merge 2 mySQL Databases using OdbcDataAdapter.Update
- From: den 2005
- Re: Unable to merge 2 mySQL Databases using OdbcDataAdapter.Update
- From: Cor Ligthert [MVP]
- Re: Unable to merge 2 mySQL Databases using OdbcDataAdapter.Update
- From: den 2005
- RE: Unable to merge 2 mySQL Databases using OdbcDataAdapter.Update
- Prev by Date: Re: Expression
- Next by Date: Re:DAAB, Enterprise Lib, connection timeout.
- Previous by thread: Re: Unable to merge 2 mySQL Databases using OdbcDataAdapter.Update
- Next by thread: Re: Unable to merge 2 mySQL Databases using OdbcDataAdapter.Update
- Index(es):
Relevant Pages
|