How to use ADODB.Stream for large files

B

bb2j3z

I am trying to take binary data and save to create a PDF. I think the
problem is the size of the data. Any ideas for a workaround? I am using
vb.net in asp.net

Dim BinaryStream
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("e:\websites\testfile.pdf')

I am getting an error: on the .Write command

Arguments are of the wrong type, are out of acceptable range, or are in
conflict with one another.

Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: Arguments
are of the wrong type, are out of acceptable range, or are in conflict with
one another.
 
G

Guest

I am trying to take binary data and save to create a PDF.   I think the
problem is the size of the data.   Any ideas for a workaround?   I am using
vb.net in asp.net

 Dim BinaryStream
  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("e:\websites\testfile.pdf')

I am getting an error: on the .Write command

Arguments are of the wrong type, are out of acceptable range, or are in
conflict with one another.

Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: Arguments
are of the wrong type, are out of acceptable range, or are in conflict with
one another.

Use System.IO.FileStream class to write bytes directly into a file
http://msdn2.microsoft.com/en-us/library/system.io.filestream.aspx

It has a Write method which accepts a byte
array(http://msdn2.microsoft.com/en-us/library/
system.io.filestream.write(VS.80).aspx)

Example:

Dim byteData() As Byte

Dim oFileStream As System.IO.FileStream
oFileStream = New System.IO.FileStream("testfile.pdf",
System.IO.FileMode.Create)
oFileStream.Write(byteData, 0, byteData.Length)
oFileStream.Close()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top