Click here to Skip to main content
15,885,309 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
I am using C#,asp.net 2.0,sql server 2005 and visual studio 2005
Can anybody help with the following problem:

i have successfully uploaded image file into the database(where i have used image datatype).

now my problem is: How to retrieve that binary data (image file) from that table and insert it in another table(again store it as binary data) and display it in aspx page.


please help me.
Thanks in Advance.
Regards,
Karan
Posted
Comments
virang_21 16-Jun-11 19:01pm    
You can create a handler .ashx that will retrieve it from database and then you can bind it to image control.

1 solution

Hope this[^] might help you.
 
Share this answer
 
Comments
karan joshua 16-Jun-11 3:38am    
<pre> SqlCommand cmdSelect = new SqlCommand("SELECT ImageFile FROM MyImageTable WHERE ImgID ='" + ImgIDTextBox.Text + "'", connection,st);



byte[] barrImg = (byte[])cmdSelect.ExecuteScalar();
string sqlquery1 = "insert into myTable(ImageFile) values('"+barrImg+"')";

command1 = new SqlCommand(sqlquery1, connection,st);

int numTo = command1.ExecuteNonQuery();

</pre>

i have used above code to insert into another table.In sql server database it shows column ImageFile with binary data

when i display it in image control using handler it won't show any image.

what is problem in code?

plz help me...

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