DataSet Issues

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi group,

Am bit stuck again.

well,I have a dataset with 14 tables,I return this dataset to my PocketPc
Device it's fine,surprisingly fast too..but now i want to split each table in
this dataset into individual dataset so i can save it in xml on device for
later use.using ds.writexml method. below is the code snippet

ds = objWebService1.RetrieveInitializeData()

dt= ds .table1

dsLookup.Tables.Add(dt) <-- get error over here saying "Table already
belongs to this DataSet"

Me.WriteToOffline
(dsLookup, "\ProgramFiles\HandIT2Sage\Data\UserOptions.xml")

Basically i want to split the tables in the dataset into individual datasets

Any Ideas!!!!

Regards

Salim G Belim
 
Salim,

So what you need are 14 new datasets. Assuming "ds" is the dataset that
contains the
14 tables you want to split across individual datasets, do this 14 times:

DataSet ds1 = new DataSet();
ds1.Tables.Add(ds.Tables[0]);

......ending with.....
DataSet ds14 = new DataSet();
ds14.Tables.Add(ds.Tables[13]);

Then save all 14 of the datasets you have created.
- Darren
 
Hi Darren,

thanks,but when i do ds1.Tables.Add(ds.Tables[0]);
it gives me error ""Table already belongs to this DataSet"


Regards
Salim


Darren Shaffer said:
Salim,

So what you need are 14 new datasets. Assuming "ds" is the dataset that
contains the
14 tables you want to split across individual datasets, do this 14 times:

DataSet ds1 = new DataSet();
ds1.Tables.Add(ds.Tables[0]);

......ending with.....
DataSet ds14 = new DataSet();
ds14.Tables.Add(ds.Tables[13]);

Then save all 14 of the datasets you have created.
- Darren

salim said:
Hi group,

Am bit stuck again.

well,I have a dataset with 14 tables,I return this dataset to my PocketPc
Device it's fine,surprisingly fast too..but now i want to split each table
in
this dataset into individual dataset so i can save it in xml on device for
later use.using ds.writexml method. below is the code snippet

ds = objWebService1.RetrieveInitializeData()

dt= ds .table1

dsLookup.Tables.Add(dt) <-- get error over here saying "Table already
belongs to this DataSet"

Me.WriteToOffline
(dsLookup, "\ProgramFiles\HandIT2Sage\Data\UserOptions.xml")

Basically i want to split the tables in the dataset into individual
datasets

Any Ideas!!!!

Regards

Salim G Belim
 
Sorry Salim, my mistake - once a DataTable is added to a DataSet, you can
remove it but
the only way I know to de-attach it so that it's contents can be reused is
to define a new
DataTable as the Clone() of the existing one (gets the schema), iterate
through the existing one,
and insert each row into the new one, effectively performing a copy of the
original DataTable.
Once you've got the copy you can Remove() the old DataTable from the
original DataSet.

-Darren

salim said:
Hi Darren,

thanks,but when i do ds1.Tables.Add(ds.Tables[0]);
it gives me error ""Table already belongs to this DataSet"


Regards
Salim


Darren Shaffer said:
Salim,

So what you need are 14 new datasets. Assuming "ds" is the dataset that
contains the
14 tables you want to split across individual datasets, do this 14 times:

DataSet ds1 = new DataSet();
ds1.Tables.Add(ds.Tables[0]);

......ending with.....
DataSet ds14 = new DataSet();
ds14.Tables.Add(ds.Tables[13]);

Then save all 14 of the datasets you have created.
- Darren

salim said:
Hi group,

Am bit stuck again.

well,I have a dataset with 14 tables,I return this dataset to my
PocketPc
Device it's fine,surprisingly fast too..but now i want to split each
table
in
this dataset into individual dataset so i can save it in xml on device
for
later use.using ds.writexml method. below is the code snippet

ds = objWebService1.RetrieveInitializeData()

dt= ds .table1

dsLookup.Tables.Add(dt) <-- get error over here saying "Table
already
belongs to this DataSet"

Me.WriteToOffline
(dsLookup, "\ProgramFiles\HandIT2Sage\Data\UserOptions.xml")

Basically i want to split the tables in the dataset into individual
datasets

Any Ideas!!!!

Regards

Salim G Belim
 
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.

--------------------
 
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


"Ilya Tumanov [MS]" said:
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: <[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!TK2MSFTNGXA03.phx.gbl
Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.framework.compactframework:66125
X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework

Hi group,

Am bit stuck again.

well,I have a dataset with 14 tables,I return this dataset to my PocketPc
Device it's fine,surprisingly fast too..but now i want to split each table in
this dataset into individual dataset so i can save it in xml on device for
later use.using ds.writexml method. below is the code snippet

ds = objWebService1.RetrieveInitializeData()

dt= ds .table1

dsLookup.Tables.Add(dt) <-- get error over here saying "Table already
belongs to this DataSet"

Me.WriteToOffline
(dsLookup, "\ProgramFiles\HandIT2Sage\Data\UserOptions.xml")

Basically i want to split the tables in the dataset into individual datasets

Any Ideas!!!!

Regards

Salim G Belim
 
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]>
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


"Ilya Tumanov [MS]" said:
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: <[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!TK2MSFTNGXA03.phx.gbl
Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.framework.compactframework:66125
X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework

Hi group,

Am bit stuck again.

well,I have a dataset with 14 tables,I return this dataset to my PocketPc
Device it's fine,surprisingly fast too..but now i want to split each table in
this dataset into individual dataset so i can save it in xml on
device
for
later use.using ds.writexml method. below is the code snippet

ds = objWebService1.RetrieveInitializeData()

dt= ds .table1

dsLookup.Tables.Add(dt) <-- get error over here saying "Table already
belongs to this DataSet"

Me.WriteToOffline
(dsLookup, "\ProgramFiles\HandIT2Sage\Data\UserOptions.xml")

Basically i want to split the tables in the dataset into individual datasets

Any Ideas!!!!

Regards

Salim G Belim
 
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


"Ilya Tumanov [MS]" said:
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]>
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


"Ilya Tumanov [MS]" said:
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: <[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!TK2MSFTNGXA03.phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.compactframework:66125
X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework

Hi group,

Am bit stuck again.

well,I have a dataset with 14 tables,I return this dataset to my PocketPc
Device it's fine,surprisingly fast too..but now i want to split each
table in
this dataset into individual dataset so i can save it in xml on device
for
later use.using ds.writexml method. below is the code snippet

ds = objWebService1.RetrieveInitializeData()

dt= ds .table1

dsLookup.Tables.Add(dt) <-- get error over here saying "Table
already
belongs to this DataSet"

Me.WriteToOffline
(dsLookup, "\ProgramFiles\HandIT2Sage\Data\UserOptions.xml")

Basically i want to split the tables in the dataset into individual
datasets

Any Ideas!!!!

Regards

Salim G Belim
 
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]>
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


"Ilya Tumanov [MS]" said:
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]>
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: <[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!TK2MSFTNGXA03.phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.compactframework:66125
X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework

Hi group,

Am bit stuck again.

well,I have a dataset with 14 tables,I return this dataset to my PocketPc
Device it's fine,surprisingly fast too..but now i want to split each
table in
this dataset into individual dataset so i can save it in xml on device
for
later use.using ds.writexml method. below is the code snippet

ds = objWebService1.RetrieveInitializeData()

dt= ds .table1

dsLookup.Tables.Add(dt) <-- get error over here saying "Table
already
belongs to this DataSet"

Me.WriteToOffline
(dsLookup, "\ProgramFiles\HandIT2Sage\Data\UserOptions.xml")

Basically i want to split the tables in the dataset into individual
datasets

Any Ideas!!!!

Regards

Salim G Belim
 
Hi Ilya,

It would be great if you can show me a sample code :-))

Regards
Salim

"Ilya Tumanov [MS]" said:
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]>
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


"Ilya Tumanov [MS]" said:
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: <[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!TK2MSFTNGXA03.phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.compactframework:66125
X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework

Hi group,

Am bit stuck again.

well,I have a dataset with 14 tables,I return this dataset to my
PocketPc
Device it's fine,surprisingly fast too..but now i want to split each
table in
this dataset into individual dataset so i can save it in xml on
device
for
later use.using ds.writexml method. below is the code snippet

ds = objWebService1.RetrieveInitializeData()

dt= ds .table1

dsLookup.Tables.Add(dt) <-- get error over here saying "Table
already
belongs to this DataSet"

Me.WriteToOffline
(dsLookup, "\ProgramFiles\HandIT2Sage\Data\UserOptions.xml")

Basically i want to split the tables in the dataset into individual
datasets

Any Ideas!!!!

Regards

Salim G Belim
 
// Create DataSet.
DataSet ds = new DataSet();
// Fill it with data here ...

// Save it

// Open writer
XmlTextWriter xtw = new XmlTextWriter(new StreamWriter("data.xml"));
// Start document
xtw.WriteStartDocument(true);
// Write DataSet tag <DataSet>
xtw.WriteStartElement("DataSet");
// Append schema
ds.WriteXmlSchema(xtw);
// Append data in diffgram mode
ds.WriteXml(xtw, XmlWriteMode.DiffGram);
// Write closing tag
xtw.WriteEndElement();
// Write end documant
xtw.WriteEndDocument();
// Close it
xtw.Close();

// Now read it back

DataSet ds1 = new DataSet();
// No need to do anything, format will be recognized automatically.
ds1.ReadXml("data.xml");

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
Thread-Topic: DataSet Issues
thread-index: AcTbdXdqoS3OL+ajR0SSw4cmoA8BUw==
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: Mon, 6 Dec 2004 01:25:03 -0800
Lines: 302
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:66367
X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework

Hi Ilya,

It would be great if you can show me a sample code :-))

Regards
Salim

"Ilya Tumanov [MS]" said:
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]>
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:
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!TK2MSFTNGXA03.phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.compactframework:66125
X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework

Hi group,

Am bit stuck again.

well,I have a dataset with 14 tables,I return this dataset to my
PocketPc
Device it's fine,surprisingly fast too..but now i want to
split
each
table in
this dataset into individual dataset so i can save it in xml on
device
for
later use.using ds.writexml method. below is the code snippet

ds = objWebService1.RetrieveInitializeData()

dt= ds .table1

dsLookup.Tables.Add(dt) <-- get error over here saying "Table
already
belongs to this DataSet"

Me.WriteToOffline
(dsLookup, "\ProgramFiles\HandIT2Sage\Data\UserOptions.xml")

Basically i want to split the tables in the dataset into individual
datasets

Any Ideas!!!!

Regards

Salim G Belim
 
Thats great ...

Thanks Ilya

Regards
Salim

"Ilya Tumanov [MS]" said:
// Create DataSet.
DataSet ds = new DataSet();
// Fill it with data here ...

// Save it

// Open writer
XmlTextWriter xtw = new XmlTextWriter(new StreamWriter("data.xml"));
// Start document
xtw.WriteStartDocument(true);
// Write DataSet tag <DataSet>
xtw.WriteStartElement("DataSet");
// Append schema
ds.WriteXmlSchema(xtw);
// Append data in diffgram mode
ds.WriteXml(xtw, XmlWriteMode.DiffGram);
// Write closing tag
xtw.WriteEndElement();
// Write end documant
xtw.WriteEndDocument();
// Close it
xtw.Close();

// Now read it back

DataSet ds1 = new DataSet();
// No need to do anything, format will be recognized automatically.
ds1.ReadXml("data.xml");

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
Thread-Topic: DataSet Issues
thread-index: AcTbdXdqoS3OL+ajR0SSw4cmoA8BUw==
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: Mon, 6 Dec 2004 01:25:03 -0800
Lines: 302
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:66367
X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework

Hi Ilya,

It would be great if you can show me a sample code :-))

Regards
Salim

"Ilya Tumanov [MS]" said:
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:
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!TK2MSFTNGXA03.phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.compactframework:66125
X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework

Hi group,

Am bit stuck again.

well,I have a dataset with 14 tables,I return this dataset to my
PocketPc
Device it's fine,surprisingly fast too..but now i want to split
each
table in
this dataset into individual dataset so i can save it in xml on
device
for
later use.using ds.writexml method. below is the code snippet

ds = objWebService1.RetrieveInitializeData()

dt= ds .table1

dsLookup.Tables.Add(dt) <-- get error over here saying
"Table
already
belongs to this DataSet"

Me.WriteToOffline
(dsLookup, "\ProgramFiles\HandIT2Sage\Data\UserOptions.xml")

Basically i want to split the tables in the dataset into
individual
datasets

Any Ideas!!!!

Regards

Salim G Belim
 
Back
Top