Click here to Skip to main content
16,004,919 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi...

I want to retrieve pdf from sqlserver database.In my database,pdf stored in varbinary datatype.I retrived pdf using path.

But my requirement is...

directly i want to retrieve from database.

Please give me any suggestion..

Thanks,
swathi
Posted
Comments
Muralikrishna8811 13-Apr-12 8:47am    
Hi do same as how you retrieve data from sqlserver

but needs to store in byte[]
da.fill(dt);//here da is dataadapter and dt is data tble instances
byte[] pdffilebuffer=(byte[])dt.rows[0][0];

1 solution

You can get the file out of the DB as a byte[]. That byte array you can put into a System.IO.Stream object. You can save that object to file or pass it to what you want to do with it.

If it's Asp.Net you probably want to show it. In that case I would save it in a temp folder and or link to it or open another window where url = pdf document.

If the user is done with it, you need to delete the temporary file again.

Hope this helps.
 
Share this answer
 

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