You can do it by creating XmlTextWriter, writing a DataSet tag (say,
<DataSet>), appending schema using WriteXmlSchema(), appending data using
WriteXml() with diffgram option and writing closing DataSet tag. No special
processing would be needed to read the data; schema will be detected and
loaded automatically, as well as diffgram format will be recognized.
Best regards,
Ilya
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
Thread-Topic: DataSet Issues
thread-index: AcTZG18RZoRjs0bJRZms7svecfKtaQ==
X-WBNR-Posting-Host: 213.40.196.128
From: "=?Utf-8?B?c2FsaW0=?=" <
[email protected]>
References: <
[email protected]>
<
[email protected]>
<
[email protected]>
<
[email protected]>
Subject: RE: DataSet Issues
Date: Fri, 3 Dec 2004 01:35:05 -0800
Lines: 232
Message-ID: <
[email protected]>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 8bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.framework.compactframework
NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.compactframework:66268
X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
Hi Guys,
I managed to get diffgram working, but Again i have a question.
Well,I bringing down typed dataset using webservice(offcourse i have to
modify the webreference of webservice) and i need to save the dataset in
xml
as diffgram,so my code is below.
Public Function writeXML(ByVal ds As DataSet, ByVal FileName As String,
ByVal SchemaName As String) As Boolean
Dim CatalogFile As FileInfo
Dim dir As DirectoryInfo
Dim stream As StreamWriter = Nothing
Dim writer As XmlTextWriter = Nothing
Dim isOk As Boolean
Try
'Create application directory if it doesn’t exist
dir = New DirectoryInfo("\Program Files\MySystem\Data")
If (Not dir.Exists) Then
dir.Create()
End If
stream = New StreamWriter(FileName)
writer = New XmlTextWriter(stream)
If (Not (ds.Tables.Count = 0)) Then
' Save out to file
ds.WriteXml(writer, XmlWriteMode.DiffGram)
'write schema
ds.WriteXmlSchema(SchemaName)
End If
isOk = True
Catch ex As Exception
isOk = False
Finally
If Not (stream Is Nothing) Then
stream.Close()
End If
End Try
Return isOk
End Function
End Class
No my question is do i have to save both the schema and xml as i tried
just
saving the xml using diffgram when i view the xml it have no schema
inside...just the <diffgr:diffgram xmlns:....... stuff><MyNew>... data
</mynew></diffgr:diffgram >
"NO Schema" so i had to save the schema seperately and then load the
schema
and xml using readxml to populate the dataset.
Any ideas how to save the diffgram + data + schema in one single xml
file???
Regards
Salim
:
Yes, you can use diffgram in CF.
You should use overloads below and specify XmlWriteMode.DiffGram to
save
XML as diffgram.
XmlReadMode.DiffGram can be specified for ReadXml, but it's optional as
diffgram will be automatically recognized.
Do not forget to load schema into the dataset first, diffgram mode
needs
schema to be loaded or data from XML will be ignored.
public XmlReadMode ReadXml(XmlReader reader,XmlReadMode mode);
public void WriteXml(XmlWriter writer,XmlWriteMode mode);
As to comparing XML, it's not the best solution. Compare datasets
instead
if you have to do that.
Best regards,
Ilya
This posting is provided "AS IS" with no warranties, and confers no
rights.
--------------------
Thread-Topic: DataSet Issues
thread-index: AcTYUjI0y7WFmMm5QRGaf9OEUIHxUg==
X-WBNR-Posting-Host: 213.40.196.128
From: "=?Utf-8?B?c2FsaW0=?=" <
[email protected]>
References: <
[email protected]>
<
[email protected]>
Subject: RE: DataSet Issues
Date: Thu, 2 Dec 2004 01:35:01 -0800
Lines: 107
Message-ID: <
[email protected]>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.framework.compactframework
NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.compactframework:66193
X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
Hi Guys,
Sorry couldn't catch up my own post ,it's seems time difference
anyway i
solve the probelm
solution was i remove the table from dslookup and add to another
dataset
an
surprisingly it works it seems the datatable is stored in dataset by
reference.
Dim dsFinal as new dataset
ds = objWebService1.RetrieveInitializeData()
dsLookup = ds
dttbl_user_options = dsLookup.Tables(2)
dsLookup.Tables.Remove(dttbl_user_options)
dsFinal.Tables.Add(dttbl_user_options)
Has any one used diffgram in compact framework (can we use it?),any
articles/links to compare two dataset using diffgram?
Regards
Salim
:
You can't do that; DataTable can only belong to one DataSet.
Please remove DataTable from original DataSet before adding it to
another
one or clone it.
Another solution would be to save all tables at ones by saving
original
DataSet to XML.
That would preserve relations you might have (and its one line of
code).
Also make sure 'dsLookup' is not the same as 'ds' (as exception
message
suggests).
Should they be different, you'll get an exception with the
following
message: "DataTable already belongs to another DataSet".
Best regards,
Ilya
This posting is provided "AS IS" with no warranties, and confers no
rights.
--------------------
Thread-Topic: DataSet Issues
thread-index: AcTXvLi+xKW/Rhr2Qk6Y3NWGmInE5A==
X-WBNR-Posting-Host: 213.40.196.128
From: "=?Utf-8?B?c2FsaW0=?=" <
[email protected]>
Subject: DataSet Issues
Date: Wed, 1 Dec 2004 07:45:02 -0800
Lines: 29
Message-ID: