Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DTS VBScript ADODB.Stream Error

Status
Not open for further replies.

ejc00

MIS
Jul 22, 2001
114
US
I am trying to run a DTS package using the ActiveX task to export files from a table in SQL Server using the ADODB.Stream method. I am using the following code:

Connection:
set myConn = CreateObject("ADODB.Connection")
myConn.Open = "Provider=SQLOLEDB.1;Data Source=servername;Initial Catalog=databasename;user id = 'userID';password='password'"

Recordset:
set rst = CreateObject("ADODB.Recordset")
rst.Open strSQL, myConn

Write from Stream:
Do Until rst.EOF
Set mstream = CreateObject("ADODB.Stream")
mstream.mode = adModeReadWrite
mstream.Open
mstream.Write rst.Fields("doccontent").Value
mstream.SaveToFile strPath, strDocName, adSaveCreateOverWrite
mstream.Close
rst.movenext
Loop

This code is erroring out on the "mstream.Write" line. I get the following error:
"Operation is not allowed in this context."

This is the error as it appears in the error log:
Error on Line 67
(ADODB.Stream (800a0c93): Operation is not allowed in this context.)
Step Error code: 800403FE
Step Error Help File:sqldts80.hlp
Step Error Help Context ID:1100


Any help on how to get this to work properly would be greatly appreciated. This method works in Visual Basic, but I would like to run it from a DTS package -- so I know the data is being pulled properly. I'm just not sure if I am connecting or opening the stream correctly in SQL Server.

Thanks,
ejc
 
What's on line 67?

Phil Hegedusich
Senior Web Developer
IIMAK
-----------
Boy howdy, my Liberal Studies degree really prepared me for this....
-----------
A skeleton walks into a bar, and says "I'll have a beer and a mop.
 
Line 67 is the code to write the content of the field in the recordset to the Stream object:

mstream.Write rst.Fields("doccontent").Value
 
philhege? do you have any ideas what could be causing this error?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top