Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pictures in a database 1

Status
Not open for further replies.

capone67

Programmer
Nov 6, 2000
115
CA
Does anyone know how to insert a picture into a database using an SQL statement? I also need to know how to retrieve that image from the database and load it into a picture box.

Ken
 
The only way I know is to write the contents of the picturebox to a temporary file, then read in the file (in banary mode) then use the AppendChunck method to build the field (which is an OLE field).

To get the picture back, you do the reverse except you use GetChunck instead of AppendChunck.

I have done it an the application works fine.

Do you need more info??

Greg. "Life is full of learning, and then there is wisdom"
 
I am gonna need moe info if I go this route. The image needs to be loaded into the database suing activer server pages and retrieved using a vb application. Does this complicate things?

Ken
 
Using ASP should not be a problem because:

1) To put the image in the DB: use "SavePicture" to write the image to a tempory file, then using "InputB" to read it in and for each InputB chunck using .AppendChunck (iteratively) to build the field.

2) To get the image from the DB: use .GetChunck to grab each part of the field and write it to a temp file then use the "LoadPicture" function to save the image.

The documentation in the MSDN is quite extensive on this.

Is this enough info?
"Life is full of learning, and then there is wisdom"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top