Save/Retrieve Image From SQL Server Database Using Ado 2.5 Stream Object

Category:
Database
Type:
Snippets
Difficulty:
Intermediate
Author:
Michael P. Gerety

Version Compatibility: Visual Basic 6

More information:
*** NOTE *** You MUST Use ActiveX Data Objects 2.5 or HIGHER

I had been trying to use the AppendChunk()/GetChunk() functions with SQL Server 7.0 to no avail as when I did a select statement on my table which housed a column of type "Image", the dataType and Format were "unsupported" by VB.

Using the ADO Stream object it is much easier to get/retrieve image data from a SQL Server Database. Below is a very simplified version of my code.

Instructions: Copy the declarations and code below and paste directly into your VB project.

Declarations:

Code: