Solved

SQL TEXT field to Stream?

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

821 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