PC Review


Reply
Thread Tools Rate Thread

Diffgram,XML and writeXML

 
 
=?Utf-8?B?c2FsaW0=?=
Guest
Posts: n/a
 
      8th Dec 2004
Hi guys,

whats wrong with below code!!!!!! it just doesn't work

All i want to do is Return my typed dataset as diffgram in bytes and receive
it in my PPC application and convert it back to dataset

WebService code Snippet:

myDsHandIT2.WriteXml(stream, XmlWriteMode.DiffGram)
myBytes = stream.ToArray()
return myBytes

PPC Code Snippet :


Dim myBytes() As Byte
Try
myBytes = objHandIT2.TestLoadData(Me.mUsername, Me.mPassword,

Me.mWebServiceUrl, Me.IPAddress)
strresult = utf.GetString(myBytes, 0, myBytes.Length)
Me.writeXML(strresult, "\Program Files\Data\test.xml", "\Program
Files\Data\test.xsd")
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try


Public Function writeXML(ByVal myStream As String, ByVal FileName As
String, ByVal SchemaName As String) As Boolean

Dim stream As StreamWriter = Nothing
Dim writer As XmlTextWriter = Nothing
Dim isOk As Boolean
Dim ds As New DataSet

Try
stream = New StreamWriter(myStream) <---------- Goes bang over
here
writer = New XmlTextWriter(stream)

If (Not (ds.Tables.Count = 0)) Then
' Save out to file
ds.WriteXml(writer, XmlWriteMode.DiffGram)
'write schema also
ds.WriteXmlSchema(SchemaName)
End If

isOk = True
Catch ex As Exception
isOk = False
MessageBox.Show(ex.ToString)
Finally
If Not (stream Is Nothing) Then
stream.Close()
End If
End Try
Return isOk
End Function

Regards

Salim
 
Reply With Quote
 
 
 
 
=?Utf-8?B?QWxleCBZYWtobmluIFtNVlBd?=
Guest
Posts: n/a
 
      8th Dec 2004
StreamWriter doesn't accept a xml data string in it's constructor, it's a
path to the file. Instead, you could use the MemoryStream:

Dim ms As MemoryStream = NewMemoryStream(myBytes)

writer = New XmlTextWriter(ms)

HTH... Alex
--
Alex Yakhnin, .NET CF MVP
www.intelliprog.com
www.opennetcf.org

"salim" wrote:

> Hi guys,
>
> whats wrong with below code!!!!!! it just doesn't work
>
> All i want to do is Return my typed dataset as diffgram in bytes and receive
> it in my PPC application and convert it back to dataset
>
> WebService code Snippet:
>
> myDsHandIT2.WriteXml(stream, XmlWriteMode.DiffGram)
> myBytes = stream.ToArray()
> return myBytes
>
> PPC Code Snippet :
>
>
> Dim myBytes() As Byte
> Try
> myBytes = objHandIT2.TestLoadData(Me.mUsername, Me.mPassword,
>
> Me.mWebServiceUrl, Me.IPAddress)
> strresult = utf.GetString(myBytes, 0, myBytes.Length)
> Me.writeXML(strresult, "\Program Files\Data\test.xml", "\Program
> Files\Data\test.xsd")
> Catch ex As Exception
> MessageBox.Show(ex.ToString)
> End Try
>
>
> Public Function writeXML(ByVal myStream As String, ByVal FileName As
> String, ByVal SchemaName As String) As Boolean
>
> Dim stream As StreamWriter = Nothing
> Dim writer As XmlTextWriter = Nothing
> Dim isOk As Boolean
> Dim ds As New DataSet
>
> Try
> stream = New StreamWriter(myStream) <---------- Goes bang over
> here
> writer = New XmlTextWriter(stream)
>
> If (Not (ds.Tables.Count = 0)) Then
> ' Save out to file
> ds.WriteXml(writer, XmlWriteMode.DiffGram)
> 'write schema also
> ds.WriteXmlSchema(SchemaName)
> End If
>
> isOk = True
> Catch ex As Exception
> isOk = False
> MessageBox.Show(ex.ToString)
> Finally
> If Not (stream Is Nothing) Then
> stream.Close()
> End If
> End Try
> Return isOk
> End Function
>
> Regards
>
> Salim

 
Reply With Quote
 
Ilya Tumanov [MS]
Guest
Posts: n/a
 
      8th Dec 2004
If you return a DataSet directly, it will be serialized as a diffgram
anyway.
I would suggest dropping byte array idea as it would cause serious
performance hit for double serialization/deserialization without really
affecting data over wire.

If you have problems returning typed DataSet, you can:

a) Change your web method to return untyped DataSet.
b) Tweak the proxy code so it would use untyped DataSet.
c) Tweak typed DataSet code so it would work on CF (or use CF typed DataSet
generator freely available on the web).

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
> Thread-Topic: Diffgram,XML and writeXML
> thread-index: AcTdDWSnga1oj0LITSu202TuXdDNQw==
> X-WBNR-Posting-Host: 213.40.196.128
> From: "=?Utf-8?B?c2FsaW0=?=" <(E-Mail Removed)>
> Subject: Diffgram,XML and writeXML
> Date: Wed, 8 Dec 2004 02:05:06 -0800
> Lines: 64
> Message-ID: <FA7C35EC-E0D3-408B-9285-(E-Mail Removed)>
> 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:66506
> X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
>
> Hi guys,
>
> whats wrong with below code!!!!!! it just doesn't work
>
> All i want to do is Return my typed dataset as diffgram in bytes and

receive
> it in my PPC application and convert it back to dataset
>
> WebService code Snippet:
>
> myDsHandIT2.WriteXml(stream, XmlWriteMode.DiffGram)
> myBytes = stream.ToArray()
> return myBytes
>
> PPC Code Snippet :
>
>
> Dim myBytes() As Byte
> Try
> myBytes = objHandIT2.TestLoadData(Me.mUsername, Me.mPassword,
>
> Me.mWebServiceUrl, Me.IPAddress)
> strresult = utf.GetString(myBytes, 0, myBytes.Length)
> Me.writeXML(strresult, "\Program Files\Data\test.xml", "\Program
> Files\Data\test.xsd")
> Catch ex As Exception
> MessageBox.Show(ex.ToString)
> End Try
>
>
> Public Function writeXML(ByVal myStream As String, ByVal FileName As
> String, ByVal SchemaName As String) As Boolean
>
> Dim stream As StreamWriter = Nothing
> Dim writer As XmlTextWriter = Nothing
> Dim isOk As Boolean
> Dim ds As New DataSet
>
> Try
> stream = New StreamWriter(myStream) <---------- Goes bang

over
> here
> writer = New XmlTextWriter(stream)
>
> If (Not (ds.Tables.Count = 0)) Then
> ' Save out to file
> ds.WriteXml(writer, XmlWriteMode.DiffGram)
> 'write schema also
> ds.WriteXmlSchema(SchemaName)
> End If
>
> isOk = True
> Catch ex As Exception
> isOk = False
> MessageBox.Show(ex.ToString)
> Finally
> If Not (stream Is Nothing) Then
> stream.Close()
> End If
> End Try
> Return isOk
> End Function
>
> Regards
>
> Salim
>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dataset Diffgram... I think... Scott Meddows Microsoft VB .NET 1 30th Jul 2004 08:27 AM
Diffgram Updates =?Utf-8?B?TWVybGluZSBNYXJ0aW5h?= Microsoft Dot NET 0 20th Jul 2004 05:30 AM
Generating a DiffGram Kyle Bennett Microsoft ADO .NET 0 17th Apr 2004 12:18 AM
DiffGram example for SQL Server? Maxim V. Karpov Microsoft ADO .NET 0 25th Jan 2004 05:34 PM
Re: DiffGram Ilya Tumanov [MS] Microsoft Dot NET Compact Framework 0 8th Jul 2003 11:37 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:09 PM.