Solved

Write field to a file of type html

Posted on 2008-06-16
4
769 Views
Last Modified: 2008-06-25
I have HTML text in a field.  I need to get it into a file on my server.

I am using the attached SQL code in a SPROC and need help getting it running.  By now I have completely screwed it up, so please set me straight.  At present I am getting an error -2146828212 on the 'OpenTextFile' and an error -2147211483 on the WriteLine

@AttachmentHTMLContent has already been correctly loaded with the data I want to write
@EmailAttachmentFileLocation has the full path to the filename I want to use (e.g. "D:\Folder1\Folder2\Folder3\Folder4\Folder5\Sample Doc.html")


EXECUTE @OLEResult = sp_OACreate 'Scripting.FileSystemObject', @FS OUT
PRINT @OLEResult
IF @OLEResult <> 0 PRINT 'Scripting.FileSystemObject got an error'
 
--Open a file
execute @OLEResult = sp_OAMethod @FS, 'OpenTextFile', @FileID OUT, @EmailAttachmentFileLocation, 8, 1
PRINT @OLEResult
IF @OLEResult <> 0 PRINT 'OpenTextFile got an error'
 
--Write Text1
execute @OLEResult = sp_OAMethod @FileID, 'WriteLine', Null, @AttachmentHTMLContent
PRINT @OLEResult
IF @OLEResult <> 0 PRINT 'WriteLine got an error'
EXECUTE @OLEResult = sp_OADestroy @FileID
EXECUTE @OLEResult = sp_OADestroy @FS

Open in new window

0
Comment
Question by:wsturdev
[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
  • 2
  • 2
4 Comments
 
LVL 7

Expert Comment

by:alexpercsi
ID: 21798146
Do you have to use SQL Server for this? Couldn't you use ASP.NET or another web server technology?
It's really just 5 lines of code in C#.
0
 
LVL 1

Author Comment

by:wsturdev
ID: 21798402
Sorry - can't change.
0
 
LVL 1

Accepted Solution

by:
wsturdev earned 0 total points
ID: 21798632
Stupid, Stupid, Stupid.....

I had the wrong path specified in @EmailAttachmentFileLocation !!!

Problem solved!
0
 
LVL 7

Expert Comment

by:alexpercsi
ID: 21800197
I'm glad it worked out for you :)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

763 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