Solved

SQL TEXT field to Stream?

Posted on 2007-04-10
1
274 Views
Last Modified: 2008-01-09
I have a SQL dataset with a record that has a TEXT field containing HTML.
I want to attach the HTML from the TEXT field to a Message as AlternativeView, somethng like this...

Dim htmlBody As New AlternateView("filename.htm", "text/html")
message.AlternateViews.Add(htmlBody)

Problem: AlternativeView only accepts FILE NAMES and STREAMS. How do I convert a dataset's TEXT field into a stream. ( I do NOT want to write a file!!!)
0
Comment
Question by:volking
1 Comment
 
LVL 24

Accepted Solution

by:
Jeff Certain earned 500 total points
ID: 18885957
Here you go:

      Public Function GetMemoryStream(ByVal text As String) As System.IO.MemoryStream
            Dim memStream As New System.IO.MemoryStream
            Dim data As Byte() = System.Text.Encoding.Unicode.GetBytes(text)
            memStream.Write(data, 0, data.Length)

            Return memStream
      End Function

In all fairness, I found this at http://discuss.joelonsoftware.com/default.asp?dotnet.12.365711.4
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now