Update SqlServer Table Fom xml file

  • Thread starter Thread starter chaudier
  • Start date Start date
C

chaudier

I need to update sqlServer Tables from XML files.
I use the code below but nothing is updated in my sqlServer DataBase.
What's wrong with it? (no error occurs)

objDataSetXml = new System.Data.DataSet(fileNameNode.InnerText+"Xml");
objDataSetXml.ReadXml(repImport+"/"+fileNameNode.InnerText+".xml");

objCmd = new System.Data.OleDb.OleDbDataAdapter("select * from
"+tableNameNode.InnerText,objConCnet);
objDataSetCnet = new System.Data.DataSet(tableNameNode.InnerText);
objCmd.Fill(objDataSetCnet);
objDataSetCnet.Merge(objDataSetXml, true);
objDataSetCnet.AcceptChanges();
objCmd.Update();
 
Well first the AcceptChanges, will take the all the rows in all tables, and
modify their rowstate properties to "Unchanged" this will tell the
DataAdapter that this particular row has all ready committed its changes to
the database. I would put the AcceptChanges after the Update method call.
The second thing I see is the Update method call you should be specifying the
dataset, datatable, or an array of data rows as parameter. The Update method
to my knowledge does not havea overload that accepts no parameters. I hope
this gets you in the right direction.

Keenan
 
Back
Top