Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
Working on a database driven website.
I would like to know the best practices to insert articles in to a database(MSSQL or MYSQL, any versions) and also retrieve them for display.
The articles may contain text,code and images as well(just like articles on codeproject.com)

Please suggest the best approach using asp.net and c#.

Thanks in advance!!!!
Posted

1 solution

You need to convert the file into byte[] and in database you must have a field which has binary value datatype. Just store the byte[] into that binary value field and retrieve it.
And you must know how to convert byte[] to/from file.
See examples below,
http://www.shabdar.org/sql-server/121-store-or-save-files-in-sql-server-database-using-c.html[^]
http://www.c-sharpcorner.com/UploadFile/013102/save-and-read-pdf-file-using-sql-server-and-C-Sharp/[^]
http://www.c-sharpcorner.com/blogs/6287/save-pdf-file-in-sql-server-database-using-c-sharp.aspx[^]
http://www.aspsnippets.com/Articles/Save-Files-to-SQL-Server-Database-using-FileUpload-Control.aspx[^]
-KR
 
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