如何将文章存储到数据库中? [英] How to store articles in to a database?

查看:120
本文介绍了如何将文章存储到数据库中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在数据库驱动的网站上工作。

我想知道将文章插入数据库的最佳做法(MSSQL或MYSQL,任何版本)并检索它们以供显示。

文章也可能包含文本,代码和图像(就像codeproject.com上的文章一样)



请建议使用asp.net和c#的最佳方法。



提前致谢!!!!

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!!!!

推荐答案

您需要将文件转换为byte [] ,并且在数据库中,您必须有一个二进制 value数据类型。只需将byte []存储到二进制值字段中并检索它。

你必须知道如何将byte []转换为/从文件

见下面的例子,

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
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


这篇关于如何将文章存储到数据库中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆