Solved

SQL TEXT field to Stream?

Posted on 2007-04-10
1
297 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

770 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