473,804 Members | 2,109 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ADODB.Stream into byte array


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

Thank you.
Sep 26 '06 #1
2 14299
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.co m

"bill tie" <bi*****@discus sions.microsoft .comwrote in message
news:7A******** *************** ***********@mic rosoft.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)adodbS tream;
byte[] byteArray = new byte[adodbStream.Siz e];
IntPtr ptrCharsRead = IntPtr.Zero;
iStream.Read(by teArray, adodbStream.Siz e, ptrCharsRead);

I fudged this. I'm not sure what the IntPtr business is. The documentation
says "ptrCharsRe ad" 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
6214
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 convert the byte array to binary data that the Write method will accept ?? As it always returns: Error Type: "Microsoft VBScript runtime (0x800A000D)"
1
1893
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 from the original lenght in order to get it to work as there seems to be 2 extra 0 bytes at the end. Functions included Stu
2
3717
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 send across data to the server in a serialised stream. However, when I need to geta response back to the client (.Net), I get a binary stream. What I wanna do is to convert this stream into an SByte array (The java byte is actually a signed byte,...
1
5259
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
2481
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 exceptions on various part. I have tried both AppendChunk and using a stream object. Unfortunately all the examples I can find in the Net and on the Microsoft site
2
1418
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
52271
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 StreamObject.Read(myByteArray, 0, myLength) --
0
4681
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 allways different count of rows. If anybody knows something about this kind of problem, I would appreciate any help. Thx.
7
9902
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 streams the file if the user is authorised. This has worked fine on PDFs, DOCs, XLS, etc. until today, and 18MB file presents the error message 'format error: not a pdf or corrupt'. Is there a file size limit, or a default that needs...
0
9716
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10604
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10354
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10359
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6870
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5536
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5675
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3837
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3005
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.