Solved

SQL TEXT field to Stream?

Posted on 2007-04-10
1
322 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

623 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