From: Thomas <ja...@ma...> - 2004-05-09 16:04:09
|
Hi The dataSet has changed. dataSet.HasChanges(DataRowState.Added); <--- returns true. DataSet xDataSet; xDataSet = dataSet.GetChanges(DataRowState.Added); xDataSet contains the added rows, but nothing is insert into the database table.... Regards Thomas ----- Original Message ----- From: "Cihan Karasinir" <cka...@ya...> To: "Thomas" <ja...@ma...> Sent: Sunday, May 09, 2004 4:34 AM Subject: Re: [Firebird-net-provider] using FbCommandBuilder & DataSet > I am just guessing that the RowState of the DataRow is > probably "Unchanged" rather than "Added". I don't > really know how to set it to "Added". > > You can also try to call the GetChanges() method on > your dataset and check that it has any rows. My guess > it would 0. > > I guess you could create another DataSet and iterate > through your dataset loaded from XML and Add each row > to the new DataSet thereby imitating as if you > inserting new rows. > > Let me know how you resolved the problem. > > Cihan > > --- Thomas <ja...@ma...> wrote: > > Hi > > > > I have loaded all data from a database table into a > > dataSet, and stored this dataSet to a xml file using > > the WriteXml method. > > > > Then I deleted all the data in the database table. > > > > Now I would like to read the xml file into a > > dataSet, and insert the rows from the dataSet into > > the table in the database. > > > > > > > > The code gives no error, but there are not insert > > any data into the table... > > > > FbConnection connection = > > > FirebirdUtilities.FirebirdConnection.Instance.MyConnection; > > FbDataAdapter dataAdapter = new FbDataAdapter(); > > FbTransaction transaction = > > connection.BeginTransaction(); > > dataAdapter.SelectCommand = new FbCommand("SELECT * > > FROM SYSTEMSETTINGS", connection, transaction); > > FbCommandBuilder commandBuilder = new > > FbCommandBuilder(dataAdapter); > > System.Data.DataSet dataSet; > > dataSet = new System.Data.DataSet("SYSTEMSETTINGS > > "); > > dataSet.ReadXml(savePath); > > dataAdapter.Fill(dataSet,"SYSTEMSETTINGS "); > > dataAdapter.InsertCommand = > > commandBuilder.GetInsertCommand(); > > dataAdapter.Update(dataSet, "SYSTEMSETTINGS "); > > transaction.Commit(); > > > > > > > > Can anyone see the error? > > > > Thanks > > > > Regards > > Thomas > > > > > > > > ******** Tables definitions *********** > > > > CREATE TABLE SYSTEMSETTINGS ( > > ID INTEGER NOT NULL, > > VALUE1 INTEGER, > > VALUELONG DOUBLE PRECISION); > > > > > > > > > > > > *********** XML FILE *************** > > > > <?xml version="1.0" standalone="yes" ?> > > - <SYSTEMSETTINGS> > > - <Table> > > <ID>1</ID> > > <VALUE1>0</VALUE1> > > <VALUELONG>0</VALUELONG> > > </Table> > > - <Table> > > <ID>2</ID> > > <VALUE1>25</VALUE1> > > <VALUELONG>0</VALUELONG> > > </Table> > > - <Table> > > <ID>3</ID> > > <VALUE1>4</VALUE1> > > <VALUELONG>0</VALUELONG> > > </Table> > > - <Table> > > <ID>4</ID> > > <VALUE1>5</VALUE1> > > <VALUELONG>0</VALUELONG> > > </Table> > > - <Table> > > <ID>5</ID> > > <VALUE1>1</VALUE1> > > <VALUELONG>0</VALUELONG> > > </Table> > > - <Table> > > <ID>6</ID> > > <VALUE1>3</VALUE1> > > <VALUELONG>0</VALUELONG> > > </Table> > > - <Table> > > <ID>8</ID> > > <VALUE1>0</VALUE1> > > <VALUELONG>0</VALUELONG> > > </Table> > > - <Table> > > <ID>9</ID> > > <VALUE1>1</VALUE1> > > <VALUELONG>0</VALUELONG> > > </Table> > > - <Table> > > <ID>10</ID> > > <VALUE1>2</VALUE1> > > <VALUELONG>0</VALUELONG> > > </Table> > > - <Table> > > <ID>7</ID> > > <VALUE1>0</VALUE1> > > <VALUELONG>0</VALUELONG> > > </Table> > > - <Table> > > <ID>13</ID> > > <VALUE1>0</VALUE1> > > <VALUELONG>0</VALUELONG> > > </Table> > > </SYSTEMSETTINGS> > > > > > > > > __________________________________ > Do you Yahoo!? > Win a $20,000 Career Makeover at Yahoo! HotJobs > http://hotjobs.sweepstakes.yahoo.com/careermakeover |