Discussion Locked

Load image from SQL Server into VB?

0 helpful
6 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

How do i programmically use ADO to load an image saved in SQL Server 7.0 db into VB 6.0 Picture/Image control?

Which is the better approach? stored the image as Binary inside db or store only the image link as Varchar?

6 replies

by donq

Link SQL-Server (database) to Access (database) and the software automatically writes the VBA (ADO code) statement for you IF field and table names are the same.

ODBC Database products (like SQL-Server)communicate with ODBC database products (like Access) seamlessly. If you must use pure VB you need to build your target database with the VB database engine first (which is the Access database engine by the way) and then you will have the ADO objects you need.

Good Luck.

by ohjani

The image has to be stored in SQL Server and Access option is defintely out. i know how to use ADO to retrieve string data from the db, but seems that i can't use the same approach for image (binary data) storing/retriving.

by dragon emperor

Store it as binay. Then all you need to do is use ADOs method for reading chunks out until you can assemble the whole file for putting in the picture control. ADO has corresponding methods that can write chunks of the picture back out to your database. The first time you do it, it will seem difficult if you haven't worked a lot with manipulating binary files, but after that it shouldn't be much of a problem.

This discussion is closed to new replies.