Reputation: 181
Hello Everyone I'm new in programming. I am working on small project in my project I have windows form where user will upload 4 to 6 Images and i want to store these images in SQL Database Table After that i want to retrieve these Images regarding one user.
Now my question is how can i store these images in one SQL column without any new row in Database Table?
Is it right way to store and retrieve Images ?
Upvotes: 1
Views: 2293
Reputation: 1667
If you are going to store images rather than paths in the database use a varbinary field. Once in the database it is easy to use the images in reports (ssrs) of you can extract and use in your application.
There used to be an image datatype but that is being removed. Also consider the size of the image 1MB + and you really should be storing paths.
You will need to import your image and convert to varbinary. Example:
MemoryStream ms = newMemoryStream();
pictureBox1.Image.Save(ms,ImageFormat.Jpeg);
byte[] photo_aray = newbyte[ms.Length];
ms.Position = 0;
ms.Read(photo_aray, 0, photo_aray.Length);
Here is a link to a demonstration that should help: tutorial
Upvotes: 1
Reputation: 25
You store image names in your database, and not images themselves. Also, store image names of the 4-6 pictures belonging to one customer in one cell and not a column. Try this, hope it works.
Upvotes: 1