茄子在线看片免费人成视频,午夜福利精品a在线观看,国产高清自产拍在线观看,久久综合久久狠狠综合

    <s id="ddbnn"></s>
  • <sub id="ddbnn"><ol id="ddbnn"></ol></sub>

  • <legend id="ddbnn"></legend><s id="ddbnn"></s>

    ado.net存取word及excel
    來源:易賢網(wǎng) 閱讀:864 次 日期:2014-08-20 13:58:47
    溫馨提示:易賢網(wǎng)小編為您整理了“ado.net存取word及excel”,方便廣大網(wǎng)友查閱!

    blob表

    3 id int 4 0

    0 name char 50 1

    0 blob image 16 1

    0 type char 60 1

    saveFile.aspx.cs

    PRivate void Button1_Click(object sender, System.EventArgs e)

    {

    Stream imgdatastream = File1.PostedFile.InputStream;

    int imgdatalen = File1.PostedFile.ContentLength;

    string imgtype = File1.PostedFile.ContentType;

    string name = this.getFileNameByURL(this.File1.PostedFile.FileName);

    byte[] imgdata = new byte[imgdatalen];

    int n = imgdatastream.Read(imgdata,0,imgdatalen);

    string connstr = "workstation id=OVERMIND;packet size=4096;user id=sa;passWord=sa;data source=OVERMIND;persist security info=False;initial catalog=wztj";

    SqlConnection connection = new SqlConnection(connstr);

    SqlCommand command = new SqlCommand("INSERT INTO blob(name,type,blob) VALUES ( @imgtitle, @type,@blob )", connection );

    SqlParameter paramTitle = new SqlParameter("@imgtitle", SqlDbType.VarChar,50 );

    paramTitle.Value = name;

    command.Parameters.Add(paramTitle);

    SqlParameter paramData = new SqlParameter( "@blob", SqlDbType.Image );

    paramData.Value = imgdata;

    command.Parameters.Add( paramData );

    SqlParameter paramType = new SqlParameter( "@type", SqlDbType.VarChar,50 );

    paramType.Value = imgtype;

    command.Parameters.Add( paramType );

    wztj.debug.TestSQL.TraceErrorSql("INSERT INTO blob(name,type,blob) VALUES ( @imgtitle, @type,@blob )",command.Parameters);

    connection.Open();

    int numRowsAffected = command.ExecuteNonQuery();

    connection.Close();

    }

    listFile.aspx//這個(gè)東西主要用來列表,把已經(jīng)有的東西列出來

    <asp:HyperLinkColumn DataNavigateUrlField="id" HeaderText="產(chǎn)品名稱" DataNavigateUrlFormatString="./getFile.aspx?ID={0}" DataTextField="name" DataTextFormatString="{0}" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="160px">

    listFile.aspx.cs

    string connstr="workstation id=OVERMIND;packet size=4096;user id=sa;password=sa;data source=OVERMIND;persist security info=False;initial catalog=wztj";

    SqlConnection connection = new SqlConnection(connstr);

    SqlCommand command = new SqlCommand("select * from blob", connection );

    connection.Open();

    SqlDataAdapter adaptor = new SqlDataAdapter(command);

    DataSet ds = new DataSet();

    adaptor.Fill(ds,"blob");

    connection.Close();

    this.DataGrid1.DataSource=ds.Tables["blob"].DefaultView;

    this.DataGrid1.DataBind();

    getFile.aspx.cs//這個(gè)文件比較重要負(fù)責(zé)把村道數(shù)據(jù)庫里面的文件,按照格式,按照名稱,給傳輸出來

    private void Page_Load(object sender, System.EventArgs e)

    {

    string imgid =this.Request.QueryString.Get("ID");

    //Request.QueryString["imgid"];

    string connstr="workstation id=OVERMIND;packet size=4096;user id=sa;password=sa;data source=OVERMIND;persist security info=False;initial catalog=wztj";

    string sql="SELECT name,blob, type FROM blob WHERE id = " + imgid;

    SqlConnection connection = new SqlConnection(connstr);

    SqlCommand command = new SqlCommand(sql, connection);

    connection.Open();

    SqlDataReader dr = command.ExecuteReader();

    if(dr.Read())

    {

    Response.Clear();

    Response.Buffer= true;

    Response.Charset="GB2312";

    Response.ContentEncoding=System.Text.Encoding.GetEncoding("GB2312");//設(shè)置輸出流為簡體中文

    //Response.ContentType = "application/ms-word";//設(shè)置輸出文件類型為word文件。

    Response.ContentType = dr["type"].ToString();

    Response.BinaryWrite( (byte[]) dr["blob"] );

    string FileName = dr["name"].ToString()。Trim();

    FileName=System.Web.HttpUtility.UrlEncode(FileName,System.Text.Encoding.UTF8 );

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

    }

    connection.Close();

    }

    這里要說的有兩點(diǎn),第一,就是把文件的名稱getFile.aspx變成我們想要的名稱。

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

    第二,就是把指定的名稱變成我們想要的值,是標(biāo)準(zhǔn)的中文,而不是中文的亂碼。

    FileName=System.Web.HttpUtility.UrlEncode(FileName,System.Text.Encoding.UTF8 );

    更多信息請查看IT技術(shù)專欄

    更多信息請查看網(wǎng)絡(luò)編程
    易賢網(wǎng)手機(jī)網(wǎng)站地址:ado.net存取word及excel
    由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!

    2026國考·省考課程試聽報(bào)名

    • 報(bào)班類型
    • 姓名
    • 手機(jī)號
    • 驗(yàn)證碼
    關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺(tái) | 手機(jī)站點(diǎn) | 投訴建議
    工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網(wǎng)安備53010202001879號 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號
    云南網(wǎng)警備案專用圖標(biāo)
    聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號:hfpxwx
    咨詢QQ:1093837350(9:00—18:00)版權(quán)所有:易賢網(wǎng)
    云南網(wǎng)警報(bào)警專用圖標(biāo)