Click here to Skip to main content
15,891,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear Friends,

I have SId, SName, Image, City. Now i have to upload more image for one record like following these,

SId SName Image City
------ --------- --------------------------------- -------
1 Raju Image1.jpg Image2.gif, Image3.jpg......etc Bangalore


Thanks in advance.
Posted

1 solution

1.For your current database table, it is not possible to insert multiple value for only one fields into the same record.

2.You have to refine your database by using a second table (named Images) for storing the images associated with the record from your first table:
-change your first table to have the next fields: SId, SName, City
-create a 2nd table named Images with the next fields: ID (Autonumber, PK), SId (integer FK), ImageFileName (varchar), Image (Image)
-create a FK link between these two tables by using SId from both tables;

3.For details about multiple file upload controls you could read the next articles:
http://www.itorian.com/2014/01/single-file-upload-to-multiple-file.html[^]
http://www.asp.net/ajaxlibrary/ajaxcontroltoolkitsamplesite/ajaxfileupload/ajaxfileupload.aspx[^]

4.Regarding the saving the data into the SQL tables, first your have to insert the data into your first table ==> SId, then you should iterate all files and insert a new row in the Images table by using the SId . If you want to execute all this INSERT command together you could use transaction. See details: Using Transactions in ADO.NET[^]
 
Share this answer
 
v3
Comments
Member 10021658 8-Sep-14 3:00am    
Thank you for your reply. Except fileuploadcontrol is there any control for uploading multiple images at a time. Even i don't know how to work with uploading multiple images using fileuploadcontrol also. Give the some links to me. And how to insert the record in at a time for two tables using single insert query.
Raul Iloc 8-Sep-14 3:37am    
See my update in the solution above (the 3rd and 4th points)!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900