INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

ADODB.Stream error '800a0bbc' - write to file failed.

ADODB.Stream error '800a0bbc' - write to file failed.

(OP)
Hi.
I have this page that is supposed to display a jpg image from a db on an intranet page (which works fine). I have been asked to let a user to save this jpg image save on his/her local machine when the image is displayed on the page. I used a piece of code that tsuji had posted a while back in response to a user. But, i'm getting this error when i used the code:
ADODB.Stream error '800a0bbc'
Write to file failed.
/custom_apps/property_items_list2.asp, line 111
line 111 is: .savetofile slocal,2 'save-create-overwrite
any ideas how I can correct this?
thanks.

RE: ADODB.Stream error '800a0bbc' - write to file failed.

No ideas. You need to post your code (not just the single line that is getting the error), and a link to the post that you got tsuji's code from would help too.

Silly question; why can't the user right-click the image and select "Save As..."?

RE: ADODB.Stream error '800a0bbc' - write to file failed.

(OP)
there are hundreds of images based on a page that gets the BLOB (binary large object) from an oracle DB and displays it on a page. here's the code:

CODE

surl="http://10.xxx.xxx.xxx/offimage/imagedisplay_int.asp?bookid=77863"
slocal="c:\a\fleet\" & first_name & "_" & middle_name & "_" & last_name & ".jpg"
'   on error resume next
set oxmlhttp=createobject("msxml2.xmlhttp")
if err.number<>0 then
    wscript.echo "msxml2.xmlhttp not installed. Operation aborted."
    wscript.quit(1)
end if
with oxmlhttp
    .open "get",surl,false
    .send
end with 

if err.number<>0 then
    wscript.echo "Resource unavailable for varied reasons. Operation aborted."
    set oxmlhttp=nothing : wscript.quit(2)
end if

set ostream = createobject("adodb.stream")
with ostream
    .type=1    'binary
    .mode=3    'read-write
    .open
    .write oxmlhttp.responsebody
    .savetofile slocal,2    'save-create-overwrite
    .close
end with
if err.number<>0 then
    wscript.echo "You need ado2.5 up. Operation aborted"
else
    wscript.echo "Done!" & vbcrlf & "Source : " & surl & vbcrlf & "Local : " & slocal
end if
on error goto 0
set ostream=nothing : set oxmlhttp=nothing 

RE: ADODB.Stream error '800a0bbc' - write to file failed.

What type of authentication are you using? If anonymous, then check that IUSR_servername has permission to the folder.

RE: ADODB.Stream error '800a0bbc' - write to file failed.

(OP)
the asp page is on the intranet.
the page displays an image.
i want to save the image to my local machine.
just as if i right-clicked.
i'm not sure where to use/set authentication.
thanks.

RE: ADODB.Stream error '800a0bbc' - write to file failed.

OK, starting to understand. The authentication type is set in IIS by whoever set up the website, but I don't think that's the problem now. ASP executes on a server. The "savetofile" method is being performed by the server, and the location it is saving to (C:\a\fleet\filename.jpg in your sample), would be on the server. If there is no C:\a\fleet folder on the server, you will get an error.

I have not tried doing this from an image from a database, but I have used the method in the link below to allow users to click a hyperlink, get a "Save" dialog, and save a file from my server to wherever they want on their local computer.

http://classicasp.aspfaq.com/general/how-do-i-prom...

RE: ADODB.Stream error '800a0bbc' - write to file failed.

(OP)
that's a great suggestion for a save dialog box.
but i'm trying to do this for 1000's of images automatically.

RE: ADODB.Stream error '800a0bbc' - write to file failed.

You can try saving to a folder on the server that is shared

RE: ADODB.Stream error '800a0bbc' - write to file failed.

Quote (wvdba)

but i'm trying to do this for 1000's of images automatically.

Never going to happen, not unless all your users are in a fixed environment of Windows with Infernet Exploder, so the browser can run ActieX or initiate a WSH (Windows Script Host) script.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

RE: ADODB.Stream error '800a0bbc' - write to file failed.

(OP)
ok. let's say i don't display the page and the image and just want to write the binary data to a file.
1 - i retrieve the binary data (image) from the database.
2 - how do i write this binary data to a file to be used as an image file?
in asp classic? or vb script?

RE: ADODB.Stream error '800a0bbc' - write to file failed.

(OP)
thanks chris.
the code on the link does not write the binary data (image) toto file. it just displays it on the browser. i'm able to do that. i just need the binary data to be written to a .jpg file.
thanks.

RE: ADODB.Stream error '800a0bbc' - write to file failed.

If you send the binary data with an image/jpeg ContentType header and .jpg|jpeg file extension it will be.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

RE: ADODB.Stream error '800a0bbc' - write to file failed.

(OP)
SOLVED:
here's the code that i used in vbscript that actually workd.

CODE

strCon = 'connection string for database goes here 
Set objConn = WScript.CreateObject("ADODB.Connection")      
     Set objRs = WScript.CreateObject("ADODB.Recordset")
     objConn.Open strCon

sql = "SELECT image_data from images " & _ 
       "where image_object_id between 77863 and 99999" & _ 
         "and active_flag = 'Y' " & _ 
         "and image_object_type = 'OFF_BKG' "  

Set objRs = objConn.Execute(sql) 

if Not objRS.EOF then 
   objRS.MoveFirst
else
   msgbox "no records found"
   wscript.quit
end if 

Do While Not objRS.EOF 
        i = i + 1
        oLOB = objrs.Fields.Item("image_data").Value	 
	SaveBinaryData "c:\a\fleet\photo" & i & objRS.Fields.item("image_data") 
                      &  ".jpg", oLOB
        ' images will be named photo1.jpg, photo2.jpg, photoN.jpg 
        objRS.MoveNext
Loop 
	 
objRS.Close
Set objRS = Nothing
objConn.close
Set objConn = Nothing
msgbox "finished"

' -----------------------------------------------------------

Function SaveBinaryData(FileName, ByteArray)
	Const adTypeBinary = 1
	Const adSaveCreateOverWrite = 2

	'Create Stream object
	Dim BinaryStream
	Set BinaryStream = CreateObject("ADODB.Stream")

	'Specify stream type - we want To save binary data.
	BinaryStream.Type = adTypeBinary

	'Open the stream And write binary data To the object
	BinaryStream.Open
	BinaryStream.Write ByteArray

	'Save binary data To disk
	BinaryStream.SaveToFile FileName, adSaveCreateOverWrite

	BinaryStream.Close
	Set BinaryStream = Nothing
End Function 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close