PDA

View Full Version : saving pictures in a database


steve_rm
08-09-2004, 12:53 PM
Hello,

I want to develop a simple database application using access and C#.

I did one in VB6, but can't seem to find the code to do it in C#

I have one table and want to save the customers details, and display a photo of them. But l am not sure how to store the photo and retrieve from the database.

Can anyone give me in code for this.

Many thanks in advance

Steve

Whiteknight
08-10-2004, 01:44 AM
wouldnt it be easier to simply store the photo's path in the database as a string, and keep all the photos in a folder somewhere?

steve_rm
08-10-2004, 08:10 AM
Hello,

Thanks for your reply.

Is that the best way to do this, to store the path in the database.

If l store the path in the database, if l am using access, do l use the text datatype.

Another question, what would the code be for displaying the picture in C# from the path.

Many thanks in advance

Steve

Whiteknight
08-10-2004, 11:03 AM
i dont know how to go about displaying the picture, I dont do much graphical work myself so bitmaps are beyond my expertise.

there probably is a way to store an entire picture in a database, if you write it in line by line in some sort of byte mode. unfortunately i dont know how to do it, if it's even possible.

I would say that yes, the path the the pictures should be stored in text mode, or (if you know the location of the folder where the pictures will be) you could simply store the picture name in the database, and append the folder path to the beginning of it to produce the fully qualified path to the picture file.

for instance, if you have a picture C:\my pictures\somepic.bmp, you could store the text "somepic.bmp" in the database, and declare

const char* FOLDER_PATH = "C:\\my pictures\\";

and then when you get the picture name out of the database you could simply append FOLDER_PATH to the beginning and you have your location.

after that i would probably take the lazy way out and make the function call:

system("mspaint c:\\my pictures\\somepic.bmp");

to open the picture in a premade program for showing pictures, but i realize that's probably not what you are after.

steve_rm
08-11-2004, 10:31 AM
Thanks for you help whiteknight,

I have done this before using VB6 and using a bit stream. I will do more research on that.

I will try in the way that you mentioned and store the path.

Thanks for the code.

Steve

kimo9909
09-10-2006, 11:39 PM
Here (http://msdn2.microsoft.com/en-us/library/4f5s1we0.aspx) is some info on the subject using the well known "Northwind" example that is provided by M$.