快速业务通道

asp.net关于文件在数据库的存入和读取

作者 佚名技术 来源 NET编程 浏览 发布时间 2012-05-21
rSQL += "''" + strUnitName + "'',";
184      strSQL += "''" + strTmpUserName + "'',";
185      strSQL += "''" + strDept + "'',";
186      strSQL += "''" + strUserName + "'',";
187      strSQL += "''" + strClientFileIndex + "'')";
188      cmd = new SqlCommand(strSQL, connClient);
189      cmd.Connection.Open();
190      cmd.ExecuteNonQuery();
191      cmd.Connection.Close();
192
193      String strTmpServerFileIndex = strServerFileIndex.Remove(strServerFileIndex.Length - 1);
194      
195      strSQL = "Insert Into Group_Email_Sever (Title,Content,Area,SendToUser,Dept,Sender,Files_Index)";
196      strSQL += " values (";
197      strSQL += "''" + strTitle + "'',";
198      strSQL += "''" + strContent + "'',";
199      strSQL += "''" + strAreaName + "'',";
200      strSQL += "''" + strTmpUserName + "'',";
201      strSQL += "''" + strTmpDept + "'',";
202      strSQL += "''" + strUserName + "'',";
203      strSQL += "''" + strTmpServerFileIndex + "'')";
204      cmd = new SqlCommand(strSQL, conn);
205      cmd.Connection.Open();
206      cmd.ExecuteNonQuery();
207      cmd.Connection.Close();
208    }
209    /**/////////潤崩貧勧謹現周/////////////
210    Response.Redirect("../SuccessMsg.aspx");
211  }
212}
213

下载文件的代码:

DownFile.aspx

DownFile.aspx.cs
1using System;
2using System.Data;
3using System.Configuration;
4using System.Collections;
5using System.Web;
6using System.Web.Security;
7using System.Web.UI;
8using System.Web.UI.WebControls;
9using System.Web.UI.WebControls.WebParts;
10using System.Web.UI.HtmlControls;
11
12using System.Data;
13using System.Data.SqlClient;
14using EOffice.Model;
15using EOffice.SqlServer;
16using System.IO;
17
18[Serializable]
19public partial class GroupWork_DownFile : System.Web.UI.Page
20{
21  public SqlConnection conn;
22  public String strFileID;
23  public UserInfo info;
24  protected void Page_Load(object sender, EventArgs e)
25  {
26    strFileID = Request.QueryString["ID"];
27    info = (UserInfo)Session["EOfficeUserInfo"];
28
29    if (strFileID == null)
30    {
31      Response.Redirect("../ErrorMsg.aspx");
32    }
33
34    DbLink db = new DbLink();
35    conn = db.Connect();
36
37    String strSQL = "Select * From Group_Files Where ID=" + strFileID; //+ " And SendToUser = ''" + info.UserName + "''";
38    SqlCommand cmd = new SqlCommand(strSQL, conn);
39    cmd.Connection.Open();
40    using (SqlDataReader sdr = cmd.ExecuteReader())
41    {
42      if (!s

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号