NNTP-Posting-Host: 200.138.42.69
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1111005528 29646 127.0.0.1 (16 Mar 2005 20:38:48 GMT)
X-Complaints-To: (e-mail address removed)
NNTP-Posting-Date: Wed, 16 Mar 2005 20:38:48 +0000 (UTC)
Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.
sul.t-online.de!t-online.de!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!
postnews.google.com!not-for-mail
Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.dotnet.framework.compactframework:73424
X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
I write the dataset with mutiple tables with their schema(just like
the link to posted before). I wrote 3 tables to xml file, add an entry
in one of the tables, and change entrys in the others 2 tables. When I
read that file I get no error, but the database is no updated. The
commands are correctly generated, TableNames are ok,
dsResult.Tables.Rows.Count have the number of expected rows and also
the expected data.
public static string ReadXML(SqlCeConnection DbConn, XmlTextReader
xmlr)
{
string strResult="";
DataSet dsResult;
try
{
dsResult = new DataSet();
dsResult.ReadXml(xmlr, XmlReadMode.DiffGram);
SqlCeDataAdapter adapter;
SqlCeCommandBuilder bld;
foreach (DataTable table in dsResult.Tables)
{
adapter = new SqlCeDataAdapter("SELECT * FROM "+table.TableName,
DbConn);
bld = new SqlCeCommandBuilder(adapter);
adapter.UpdateCommand = bld.GetUpdateCommand();
adapter.DeleteCommand = bld.GetDeleteCommand();
adapter.InsertCommand = bld.GetInsertCommand();
adapter.Update(dsResult, table.TableName);
}
dsResult = null;
}
catch (SqlCeException ex)
{
strResult = MakeErrorMsg(ex);
}
catch (Exception ex)
{
strResult = ex.ToString();
}
return strResult;
}
(e-mail address removed) ("Ilya Tumanov [MS]") wrote in message
Yes, it will be a valid XML. No need to do anything, just run ReadXml() on
the file and that's it.
If you want to preserve row states (which is a good idea if you're going to
update the data base), you can use diffgram format for XML.
Look into WriteXml() overload which takes XmlWriteMode argument which needs
to be set to XmlWriteMode.DiffGram.
Do not forget to load schema into the data set before loading data. Or, you
can include schema into the DiffGram.
Here's how:
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.compac
tframework/msg/036c4158cb9e6e3b
Best regards,
Ilya
This posting is provided "AS IS" with no warranties, and confers no
rights.