473,396 Members | 2,147 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

ADODB.Stream into byte array


How do I convert ADODB.Stream into an array of bytes?

Thank you.
Sep 26 '06 #1
2 14254
There really isn't a direct way to do this. The only workaround I see
is to call the SaveToFile method on the stream, and then read the bytes from
the file.

You might try and cast the Stream object to an IPersistMemory interface
instance (it is a COM interface, you might have to define it if it isn't
already defined somewhere). If that works, then you can write the contents
directly to a byte array. Either that, or the IStream COM interface (at
which point, you could read characters from the stream, and then write them
to your byte array).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"bill tie" <bi*****@discussions.microsoft.comwrote in message
news:7A**********************************@microsof t.com...
>
How do I convert ADODB.Stream into an array of bytes?

Thank you.


Sep 26 '06 #2

Nicholas, thank you for your reply.

I've used IStream. I'm getting a byte array and can work with it. This is
my code:

IStream iStream = (IStream)adodbStream;
byte[] byteArray = new byte[adodbStream.Size];
IntPtr ptrCharsRead = IntPtr.Zero;
iStream.Read(byteArray, adodbStream.Size, ptrCharsRead);

I fudged this. I'm not sure what the IntPtr business is. The documentation
says "ptrCharsRead" is a pointer to a ULONG variable that receives the actual
number of bytes read from the stream object.

How do I print the value of the ULONG variable?
Sep 26 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: JohnWayne | last post by:
Hello All, I am trying to use ADODB.Stream , to write a graphic to the asp page. However I cannot seem to send my byte Array to the objStream.Write (mybyteArray) Does anyone know how to...
1
by: Stu | last post by:
Hi, Im reading a file in from disk as a byte array then passing it to a memory stream for decryption using crypto api functions. What I have found is that you need to reduce the array length by 2...
2
by: Nick | last post by:
Hi, Problem statement: Calling a java method from Dot Net code that returns a java byte array. Overview: I have a java server from which I need to establish connection. I hva ebeen able to...
1
by: guyv | last post by:
Hello! I wanna read binary data from database with ADODB.Stream object. So I wrote code.. --------- <% query = "SELECT * FROM Categories" adoDB.DefaultDatabase = "Northwind"
0
by: Channing Jones | last post by:
Hello everyone, I am trying to store data in a binary field of an SQL-Server table using ADODB. So far, I have managed to store a record but not any data in the binary field. I only get...
2
by: Jeroen Ceuppens | last post by:
byte bytes=new byte; for (int i=0;i<50;i++) { for (int j=0;j<100;j++) bytes=i+j;
6
by: Hardy Wang | last post by:
Hi all: The Stream object from WebRequest.GetResponseStream() is non-seekable. How can I convert this stream to a byte array? For ordinary Stream (seekable), I can use...
0
by: Ireneus Broncel | last post by:
I have a class which reads Groups and Users from ActiveDirectory. The Problem is, that i have about 10000 rows as product. When I am trying to read the "memberOf" Objects out of this field i get...
7
by: iporter | last post by:
I use the code below to authorise the download of certain files. Thus, instead of linking to the file in a wwwroot directory, I link to this code with the filename as a parameter, and the script...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.