写模板后读入数据库
来源:互联网 发布:javascript的for循环 编辑:程序博客网 时间:2024/05/05 15:46
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using System.Text;
using System.IO;
using Word;
using System.Data.SqlClient;
public partial class ksyw_addword : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
wordtosql("","");
}
private void AddWord()
{
////SqlDataReader dr = DbHelperSQL.ExecuteReader("select ");
//ApplicationClass WordApp = new ApplicationClass();
//object missing = System.Reflection.Missing.Value;
//string path = Server.MapPath(".");
//path = path.Substring(0, path.Length - 10);
//string dotpath = path + "//moban//来信来访登记表.dot";
//string docpath = path + "//upload//ks//" + ajid + "//来信来访登记表.doc";
////docpath = "E://vs2005//ksyw//ajcl//c.doc";
//object tempName = @dotpath;
//object docName = @docpath;
//// object isVisible = true;
//// object readOnly = false;
//// Word.Document WordDoc = WordApp.Documents.Open(ref docName, ref missing, ref readOnly,
////ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
////ref missing, ref missing, ref isVisible, ref missing, ref missing, ref missing,ref missing);
//// WordDoc.Activate();
//// //WordApp.Selection.TypeText("This is the text");
//// // WordApp.Selection.TypeParagraph();
//// //WordDoc.Save();
//WordApp.Application.Quit(ref missing, ref missing, ref missing);
//Document MyDoc = wordApp.Documents.Add(ref tempName, ref missing, ref missing, ref missing);
//wordApp.Visible = true;
//MyDoc.Activate();
//for (int i = 1; i <= MyDoc.Bookmarks.Count; i++)
//{
// object j = i;
// Word.Range wordRng = MyDoc.Bookmarks.get_Item(ref j).Range;
// string name = MyDoc.Bookmarks.get_Item(ref j).Name;
// wordRng.Text = MyDoc.Bookmarks.get_Item(ref j).Name;
//}
////wordApp.Selection.Font.Size = 30; // 字体大小
////wordApp.Selection.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter; // 居中
////wordApp.Selection.Font.Bold = (int)WdConstants.wdToggle; // 黑体
//// wordApp.Selection.TypeText("hello");
////保存
//MyDoc.SaveAs(ref docName, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
//MyDoc.Close(ref missing, ref missing, ref missing);
//wordApp.Quit(ref missing, ref missing, ref missing);
//MyDoc = null;
//wordApp = null;
}
private void wordtosql(string filepath,string ajid)
{
StringBuilder str = new StringBuilder();
string path = Server.MapPath(".");
path = path.Substring(0, path.Length - 5);
string dotpath = path + "//moban//来信来访登记表.dot";
ajid="2009_0026";
string docpath = path + "//upload//ks//" + ajid + "//aj1cs.doc";
filepath=docpath;
if (filepath != "")
{
FileStream fs=File.OpenRead(filepath);
System.IO.BinaryReader br = null;
br = new BinaryReader((Stream)fs);
byte[] b = new byte[fs.Length];
int intLength = (int)fs.Length;
b = br.ReadBytes(intLength);
fs.Close();
str.Append("insert into ks_file(filename,ksaj_id,doccontent,filetype,doctype) values(@filename,@ksaj_id,@doccontent,@filetype,@doctype)");
SqlParameter[] p ={
new SqlParameter("@filename", SqlDbType.VarChar,50),
new SqlParameter("@ksaj_id", SqlDbType.VarChar,50),
new SqlParameter("@doccontent", SqlDbType.Image,intLength),
new SqlParameter("@filetype", SqlDbType.VarChar,50),
new SqlParameter("@doctype", SqlDbType.VarChar,50)
};
p[0].Value = "as.doc";
p[1].Value = "2009_0028";
p[2].Value =b;
p[3].Value = "证据材料";
p[4].Value = "doc";
int n= DbHelperSQL.ExecuteSql(str.ToString(), p);
if (n > 0)
{
Response.Write("dnal");
}
else
{
Response.Write("shibai");
}
}
}
}
- 写模板后读入数据库
- 读入优化的模板
- 读入优化模板
- 快速读入模板
- C++读入优化模板
- 读入优化模板
- {模板}C++读入优化
- 读入优化模板
- fread 读入挂模板
- 快速读入模板
- C++读入优化模板
- 快速读入模板
- 快速读入模板使用
- 从数据库读入
- 正负数读入优化模板
- C++读入“黑科技”模板
- uva10815 sstream文本读入模板
- freopen后重新控制台读入
- 在共享主机上搭建git服务
- C++ 编程的“深度”与“广度”
- Rainy day
- 排序算法之——选择排序
- Daily English Writting
- 写模板后读入数据库
- 科技创新实践
- 传智播客Hibernate视频教程学习笔记4
- DataTable 用法归纳
- GUI开发之JTable,实现JB属性表
- cisco ios feature : Auto secrure
- 看到新闻富士康的哥们跳了下去?问一个为什么?
- Spring可能与微软云计算平台Azure合作
- How to create/display a modal window?