I need to do a coding for inserting (done) and retrieving a image on sql using blob (binary large object) but i have sample of the previous student and i cannot do same coding as the previous student. Pls help me on the coding… ur help will be appriecated…
// Retrieving images
[SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][SIZE=2] Button1_Click([/SIZE][SIZE=2][COLOR=#0000ff]object[/COLOR][/SIZE][SIZE=2] sender, [/SIZE][SIZE=2][COLOR=#008080]EventArgs[/COLOR][/SIZE][SIZE=2] e)[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#008000]// Put user code to initialize the page here[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][SIZE=2] id = DropDownList1.SelectedItem.Value;[/SIZE]
[SIZE=2][COLOR=#008080]MemoryStream[/COLOR][/SIZE][SIZE=2] stream = [/SIZE][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][SIZE=2][COLOR=#008080]MemoryStream[/COLOR][/SIZE]SIZE=2;[/SIZE]
[SIZE=2][COLOR=#008080]SqlConnection[/COLOR][/SIZE][SIZE=2] connection = [/SIZE][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][SIZE=2][COLOR=#008080]SqlConnection[/COLOR][/SIZE]SIZE=2;[/SIZE]
[SIZE=2][COLOR=#0000ff]try[/COLOR][/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]connection.Open();[/SIZE]
[SIZE=2][COLOR=#008080]SqlCommand[/COLOR][/SIZE][SIZE=2] command = [/SIZE][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][SIZE=2][COLOR=#008080]SqlCommand[/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#800000]“select ImageBinary from ImageTable where id=”[/COLOR][/SIZE][SIZE=2] + id + [/SIZE][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE][SIZE=2], connection);[/SIZE]
[SIZE=2][COLOR=#0000ff]byte[/COLOR][/SIZE][SIZE=2][] image = ([/SIZE][SIZE=2][COLOR=#0000ff]byte[/COLOR][/SIZE][SIZE=2][])command.ExecuteScalar();[/SIZE]
[SIZE=2]stream.Write(image, 0, image.Length);[/SIZE]
[SIZE=2][COLOR=#008080]Bitmap[/COLOR][/SIZE][SIZE=2] bitmap = [/SIZE][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][SIZE=2][COLOR=#008080]Bitmap[/COLOR][/SIZE]SIZE=2;[/SIZE]
[SIZE=2]Response.ContentType = [/SIZE][SIZE=2][COLOR=#800000]“image/jpeg”[/COLOR][/SIZE][SIZE=2];[/SIZE]
[SIZE=2]bitmap.Save(Response.OutputStream, [/SIZE][SIZE=2][COLOR=#008080]ImageFormat[/COLOR][/SIZE][SIZE=2].Jpeg);[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2][COLOR=#0000ff]finally[/COLOR][/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]connection.Close();[/SIZE]
[SIZE=2]stream.Close();[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]}[/SIZE]