-
can anyone help me on retrieving images using both the sqlserver and c#
I need help on retrieving images only cos i have done the inserting images part using both sql sever and c#. My main concern is that the previous student is using this code:
protected void Button1_Click(object sender, EventArgs e)
{
string id = DropDownList1.SelectedItem.Value;
MemoryStream stream = new MemoryStream();
SqlConnection conn = new SqlConnection(@"server=blah blah");
conn.Open();
// creating Command to retrieving from table
SqlCommand cmd = new SqlCommand("SELECT ImageBinary from ImageTable where id=" + id + "", conn);
// Converting byte to image
byte[] storedImage = (byte[])cmd.ExecuteScalar();
stream.Write(storedImage, 0, storedImage.Length);
Bitmap bitmap = new Bitmap(stream);
Response.ContentType = "image/jpeg";
bitmap.Save(Response.OutputStream, ImageFormat.Jpeg);
}
and then i can't use the same coding as the previous student but i thought of using Filestream to do the code. If anyone knows how to do using filestream pls send me a post or link plus the explain how the coding works........... i will appreciate ur help =D
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks