Does anyone here know how I can retrieve the images from my database into a datalist or a datagrid?
here is my code to read it into the database:
Code:if (FileUpload1.PostedFile != null && FileUpload1.PostedFile.FileName != "") { byte[] imageSize = newbyte[FileUpload1.PostedFile.ContentLength]; HttpPostedFile uploadedImage = FileUpload1.PostedFile; uploadedImage.InputStream.Read(imageSize, 0, (int)FileUpload1.PostedFile.ContentLength); // Create SQL Connection SqlConnection conn = newSqlConnection(@"User ID=sa; Password=evolution; Initial Catalog=PE_Reunion; Data Source=(local)"); // Create SQL Command SqlCommand cmd = newSqlCommand(); cmd.CommandText = "INSERT INTO Demo(DemoImageName,DemoImage)" + " VALUES ('" + TextBox1.Text + "', @Image)"; cmd.CommandType = CommandType.Text; cmd.Connection = conn; SqlParameter ImageName = newSqlParameter("@ImageName", SqlDbType.VarChar, 50); ImageName.Value = FileUpload1.FileName; cmd.Parameters.Add(ImageName); SqlParameter UploadedImage = newSqlParameter("@Image", SqlDbType.Image, imageSize.Length); UploadedImage.Value = imageSize; cmd.Parameters.Add(UploadedImage); conn.Open(); int result = cmd.ExecuteNonQuery(); conn.Close(); if (result > 0) Label3.Text = "Demo File Uploaded and Saved"; Response.Redirect("photos.aspx"); }



AnimeGalleries [dot] Net
AnimeWallpapers [dot] Com
AnimePedia [dot] Com
AnimeGlobe [dot] Com



Making millionaires out of everyone
Bookmarks