用户登录
用户注册

分享至

asp.net怎么样将存如数据库的wor

  • 作者: 龘龘龘龘龘龘龘龘龘龘龘长
  • 来源: 51数据库
  • 2020-04-21

在ASP.NET中如何将word文档上传到SQL数据库中,急求详细实现步

同意楼上的回答。

估计楼主很少做上传的模块,一般不会把图片,视频,word文档等文件直接保存在数据库。推荐做法:把文件先上传到服务器上,然后再把相对路径存入数据库即可。

这样对于数据库来说压力很少。假入存入数据库的话,查询100条数据,每条数据都有一个word文档,每个文档大小为1MB,那么就有100MB的数据要查询出来放在内存中,如果是100万条呢?估计内存都爆了。

下面有一个完全的点net的上传例子,完全的代码,可直接运行。http://www.huhailong.cn/article_15.html如果还不懂的话,请留言。

ASP.NET中如何从数据库读取WORD文档,并保存在某个目录下(C#

public static string ConvertExcel(string strhtml,string userip) { string filepath,filename; FileStream f=null; filepath= AppDomain.CurrentDomain.SetupInformation.ApplicationBase+"\\doc\\"; filename = userip+ "temp.xls"; try { if (!Directory.Exists(filepath)) { Directory.CreateDirectory(filepath); } if (File.Exists(filepath+filename)) File.Delete(filepath+filename); f = File.Create(filepath+filename); byte[] bt = Encoding.UTF8.GetBytes(strhtml); // Encoding.GetEncoding("utf-7").GetBytes(strhtml); f.Write(bt,0,bt.Length); } catch(Exception err) { } finally { if (f != null) f.Close(); } return filename; }。

ASP.NET如何将查询出的数据存在Word文档

public void CreateExcel(DataSet ds,string typeid,string FileName)

{

HttpResponse resp;

resp = Page.Response;

resp.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");

resp.AppendHeader("Content-Disposition", "attachment;filename=" + FileName);

string colHeaders= "", ls_item="";

int i=0;

//定义表对象与行对像,同时用DataSet对其值进行初始化

DataTable dt=ds.Tables[0];

DataRow[] myRow=dt.Select("");

// typeid=="1"时导出为EXCEL格式文件;typeid=="2"时导出为XML格式文件

if(typeid=="1")

{

//取得数据表各列标题,各标题之间以\t分割,最后一个列标题后加回车符

for(i=0;i

asp.net中怎样将缓存中的数据保存到数据库中

DataTable dt = null; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindGrid(); } } private void BindGrid() { if (Cache["Products"] != null) dt = Cache["Products"] as DataTable; if (dt != null) { GridView1.DataSource = dt; GridView1.DataBind(); } } protected void btnInsert(object sender, EventArgs e) { if (Cache["Products"] != null) dt = Cache["Products"] as DataTable; //向dt加一条记录 //更新缓存 Cache["Products"] = dt; BindGrid(); } protected void btnDelete(object sender, EventArgs e) { if (Cache["Products"] != null) dt = Cache["Products"] as DataTable; //向dt加一条记录 foreach (DataRow row in dt) { //假设删除编号为3 if (Convert.ToInt32( row["id"]) == 3) { dt.Rows.Remove(row); } } //更新缓存 Cache["Products"] = dt; BindGrid(); } protected void btnSave(object sender, EventArgs e) { if (Cache["Products"] != null) dt = Cache["Products"] as DataTable; //把dt更新入库,可以遍历dt,逐行添加 }。

转载请注明出处51数据库 » asp.net怎么样将存如数据库的wor

软件
前端设计
程序设计
Java相关