如何将rtf保存到sqlserver中并检索到文本框中 [英] how to save rtf into sqlserver and retriving into textbox
本文介绍了如何将rtf保存到sqlserver中并检索到文本框中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,您能指导如何将rtf文件存储到数据库中吗?
hello, can u guide how to store rtf file into database,retriving
protected void Button1_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile && FileUpload1.PostedFile != null && FileUpload1.PostedFile.FileName != "")
{
HttpPostedFile file = FileUpload1.PostedFile;
ConvertDocToRTF("file");
}
}
public void ConvertDocToRTF(string DocPath)
{
//Create object of documnet .
Document document = new Document();
try
{
//Load doc file from given path
document.LoadFromFile(DocPath);
//Save doc file. It will convert to .Rtf format .
document.SaveToFile("Tesfile.rtf", FileFormat.Rtf);
}
catch (Exception) { throw; }
}
推荐答案
问题尚不清楚.您要存储文件本身还是仅存储内容?
如果要存储文件,则需要 ^ ]类型,更具体地说是BLOB.保留文件但不上传到数据库的另一种方法是将文件保存在DMS(文档管理系统)中,然后保存到该位置的链接.
如果您想保存rtf文本,可以通过richtextbox进行保存,尽管我不知道它如何处理复杂的文档(标题,表,图像等).
该链接在ADO.Net中有一个示例,但是任何其他提供程序都将具有类似的内容.
通读它,如果您有更具体的问题,请使用更多信息更新此问题.
希望这会有所帮助.
Question is unclear. Do you want to store the file itself, or just the contents?
If you want to store the file you need a LOB[^] type, more specifically a BLOB. An alternative in keeping the file, but not uploading to the database is saving the file in a DMS (document management system) and saving the link to the location.
If you want to save the rtf text you can do so via richtextbox, although I don''t know how it will react on complex documents (headers, tables, images, ...).
The link has a sample in ADO.Net, but any other provider will have something similar.
Read it through, if you have more specific questions, update this question with more info.
Hope this helps.
这篇关于如何将rtf保存到sqlserver中并检索到文本框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文