Click here to Skip to main content
15,888,000 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
hi can any one provide me the CODE for retrievng Filedata stored in sql server..in Form of Binary.. WINDows APPLICation
Posted
Updated 2-Nov-12 10:52am
v3
Comments
OriginalGriff 2-Nov-12 6:53am    
What have you tried so far?
Mangal Deep Gupta 2-Nov-12 6:55am    
Nothing I have No IDEA to do anythis for this
Richard MacCutchan 2-Nov-12 6:59am    
It's just data so you would get it the same way you get any other type.
fjdiewornncalwe 2-Nov-12 16:53pm    
1) You are asking us to do YOUR work for you. Wrong.
2) You appear to be too lazy to even read your question and fix your typing errors which tells me you are lazy and just want someone else to do your work for you. Wrong again.
3) With this attitude, you won't go very far as a developer because once you get out of school you actually have to know what you are doing to get anywhere.

Try:

C#
SqlConnection connection = new SqlConnection ("...");
 connection.Open ();
 // Select binary data from db
 SqlCommand command = new
   SqlCommand ("select PdfFile from Table", connection);
 byte[] buffer = (byte[]) command.ExecuteScalar ();
 connection.Close();
 // storing file to C drive
 FileStream fs = new FileStream(@"C:\test.pdf", FileMode.Create);
 fs.Write(buffer, 0, buffer.Length);
 fs.Close();
 
Share this answer
 
Comments
Shanalal Kasim 3-Nov-12 0:29am    
If it helped you to solve your problem , mark it as answer
Member 11425449 13-Feb-15 6:35am    
Sir I am use this code it should work if i can export one image, If I want to export bulk of images the it should be copied the images into the folder but that images should't be opened.
Shanalal Kasim 13-Feb-15 7:05am    
can you share your code
 
Share this answer
 
Comments
Nelek 2-Nov-12 8:15am    
OP comment moved from non-solution below:
These all example are storing IMAGE not file so i can not understand any thing from these

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