Click here to Skip to main content
15,892,737 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i studying in the NIIT of India. i have problems in project create website using ASP.Net. i want create a form upload much images in database and show its on website. who know code create its please help me. thank so much
Posted
Comments
[no name] 6-Sep-12 22:29pm    
So you have not actually tried anything? What sort of help are you looking for?

 
Share this answer
 
Comments
Hai Quan 6-Sep-12 22:37pm    
do you have know code upload so much images? hlep me. thank
Vinod Viswanath 6-Sep-12 23:45pm    
HI,

First create a table which contain image_content column of datatype image and add the following code in upload button click event.

if (FileUpload1.PostedFile != null
&& FileUpload1.PostedFile.FileName != "")
{

byte[] myimage = new byte[FileUpload1.PostedFile.ContentLength];

HttpPostedFile Image = FileUpload1.PostedFile;

Image.InputStream.Read(myimage, 0,
(int)FileUpload1.PostedFile.ContentLength);



SqlConnection myConnection =
new SqlConnection("Data Source = ComputerName\\SQLEXPRESS;
Initial Catalog= dbname; Integrated Security= SSPI");


SqlCommand storeimage =
new SqlCommand("INSERT INTO Image_Gallery "
+"(Img_Id, Image_Content, Image_Type, Image_Size) "
+" values (3, @image, @imagetype, @imagesize)"
, myConnection);


storeimage.Parameters.Add("@image",
SqlDbType.Image, myimage.Length).Value = myimage;

storeimage.Parameters.Add("@imagetype",
SqlDbType.VarChar, 100).Value
= FileUpload1.PostedFile.ContentType;

storeimage.Parameters.Add("@imagesize",
SqlDbType.BigInt, 99999).Value
= FileUpload1.PostedFile.ContentLength;

myConnection.Open();
storeimage.ExecuteNonQuery();
myConnection.Close();

Respone.Write("successfully upload the image");
}
Thanks!!
This will help you definitely, a standard all feature web starter kit and with full source code:

http://thebeerhouse.codeplex.com/[^]

The above code is very well explained and is a walkthrough it build such stuff on Wrox book:
http://p2p.wrox.com/book-asp-net-2-0-website-programming-problem-design-solution-isbn-978-0-7645-8464-0/42279-beer-house.html[^]
 
Share this answer
 

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