Results 1 to 4 of 4

Thread: String to Stream

  1. #1

    Thread Starter
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704

    String to Stream

    Say I have a String of XML text or really any text.

    How can I write that to a Stream so I can pass that into a DataSet.Read method?

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    "I have a String of XML text or really any text."

    There I said it are you happy?

    Ok, ok I'll give a real answer.
    VB Code:
    1. Dim xml As String = "<root><item name=""Ed"" id=""1""/></root>"
    2.         Dim sw As New IO.StreamWriter(New IO.MemoryStream)
    3.         'write to stream
    4.         sw.Write(xml)
    5.         'flush
    6.         sw.Flush()
    7.         'move to start of stream
    8.         sw.BaseStream.Position = 0
    9.         Dim ds As New DataSet
    10.         ds.ReadXml(sw.BaseStream)
    11.         DataGrid1.DataSource = ds

  3. #3
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682
    Originally posted by Edneeis

    VB Code:
    1. ....
    2.         'flush
    3.         sw.Flush()
    4. ....
    Who said good comments are hard to find!

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Originally I had a comment related to toliets along with that but ended up giving it the old backspace.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width