如何存取BLOB字段(word,excel)的数据? asp使用的ado就可以啊. appendchunk方法就可以 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 是的啊!同意楼上 amorg(飘雪)的!应该没有问题的 请amorg兄详细点,好吗?BLOB字段中的word,excel文档如何写到IE?WORD,EXCEL文档如何从客户端写入服务器中的BLOB字段? 现在贴代码,有两个WEBFORM,另外一个用来打开文件。我有完整的ASPX及CS文件1.输入 private void Button1_Click(object sender, System.EventArgs e) { string Inf_Title = Inf_TitleTextBox.Text.ToString().Trim(); if (Inf_Title == "") { MessLabel.Text = "标题不能为空!"; return; } string Inf_Name = Inf_NameTextBox.Text.ToString().Trim(); if (Inf_Name == "") { MessLabel.Text = "发布人不能为空!"; return; } string InvType = InvTypeTextbox.Text.ToString().Trim(); if (InvType == "") { MessLabel.Text = "型号不能为空!"; return; } if (SelectFile.PostedFile == null) { MessLabel.Text = "请你选择你要上传的文件"; return; } HttpPostedFile UpFile = SelectFile.PostedFile; //HttpPostedFile对象,用于读取文件属性 FileLength = UpFile.ContentLength; //记录文件长度 try { if (FileLength == 0) { //文件长度为零时 MessLabel.Text = "请你选择你要上传的文件"; } else { Byte[] FileByteArray = new Byte[FileLength]; //文件临时储存Byte数组 Stream StreamObject = UpFile.InputStream; //建立数据流对像 //读取文件数据,FileByteArray为数据储存体,0为数据指针位置、FileLnegth为数据长度 StreamObject.Read(FileByteArray,0,FileLength); //建立SQL Server链接 String SQLStatement = "INSERT INTO Information(标题, 时间, 撰稿人, ImageData, ImageContentType, ImageSize, ImageClass, InvType, 内容) VALUES (@Inf_Title, Getdate(), @Inf_Name, @ImageData, @ImageContentType, @ImageSize, @ImageClass, @InvType, @Inf_Text)"; SqlCommand myCommand = new SqlCommand(SQLStatement,CNN.AOSmithsqlConnection); myCommand.Parameters.Add("@Inf_Title", SqlDbType.Char,120).Value = Inf_Title; //标题 myCommand.Parameters.Add("@Inf_Name", SqlDbType.VarChar,20).Value = Inf_Name; //撰稿人 myCommand.Parameters.Add("@ImageData",SqlDbType.Binary, FileLength).Value = FileByteArray; //上传文件 myCommand.Parameters.Add("@ImageContentType", SqlDbType.VarChar,50).Value = UpFile.ContentType; //记录文件类型 myCommand.Parameters.Add("@ImageSize", SqlDbType.BigInt,8).Value = UpFile.ContentLength; //记录文件长度,读取时使用 myCommand.Parameters.Add("@ImageClass", SqlDbType.VarChar,10).Value = Session["ImageClass"].ToString(); myCommand.Parameters.Add("@InvType", SqlDbType.Char,20).Value = InvType; myCommand.Parameters.Add("@Inf_Text", SqlDbType.Text,Inf_TextTextBox.Text.Length).Value = Inf_TextTextBox.Text; CNN.AOSmithsqlConnection.Open(); myCommand.ExecuteNonQuery(); CNN.AOSmithsqlConnection.Close(); MessLabel.Text = "<p><b>OK!你已经成功上传你的文件</b>";//提示上传成功 BindDatas(); } } catch (Exception ex) { MessLabel.Text = ex.Message.ToString(); } }2.输出 private void Page_Load(object sender, System.EventArgs e) { // 在此处放置用户代码以初始化页面 if (!IsPostBack) { String SQLStatement = "SELECT * FROM Information WHERE ImageID = " + Session["ImageID"].ToString().Trim(); SqlCommand myCommand = new SqlCommand(SQLStatement,CNN.AOSmithsqlConnection); CNN.AOSmithsqlConnection.Open(); SqlDataReader SqlReader = myCommand.ExecuteReader(); SqlReader.Read(); Response.ContentType = (string)SqlReader["ImageContentType"];//设定输出文件类型 //输出图象文件二进制数制 Response.OutputStream.Write((byte[])SqlReader["ImageData"], 0, (int)SqlReader["ImageSize"]); Response.End(); CNN.AOSmithsqlConnection.Close(); } } 兼容火狐的iframe自适应高度的Js方法 xp系统下iis部署aspx网站 利用CSS设计布局效果时,在快捷菜单中没有了"添加样式规格"??? 关于头文件的Inherits的问题,有点迷茫,高手支招!!! 发布一个新站,大家给点意见 熟悉.net的条件编译的来帮忙看下,在web.config中设置的 服务器返回的信息无效或不可识别 求一个在asp.net中将DataGrid中的数据导出到EXCEL中 我用js脚本只能实现静态的树,如何实现从数据库读取数据后动态生成树? 怎样用.net发送有图片的网页邮件 菜鸟问题,大家快来抢分啊 (高分)要给部门作asp.net培训,各位有什么好的想法?
我有完整的ASPX及CS文件
1.输入 private void Button1_Click(object sender, System.EventArgs e)
{
string Inf_Title = Inf_TitleTextBox.Text.ToString().Trim();
if (Inf_Title == "")
{
MessLabel.Text = "标题不能为空!";
return;
} string Inf_Name = Inf_NameTextBox.Text.ToString().Trim();
if (Inf_Name == "")
{
MessLabel.Text = "发布人不能为空!";
return;
} string InvType = InvTypeTextbox.Text.ToString().Trim();
if (InvType == "")
{
MessLabel.Text = "型号不能为空!";
return;
} if (SelectFile.PostedFile == null)
{
MessLabel.Text = "请你选择你要上传的文件";
return;
} HttpPostedFile UpFile = SelectFile.PostedFile; //HttpPostedFile对象,用于读取文件属性
FileLength = UpFile.ContentLength; //记录文件长度 try
{
if (FileLength == 0)
{ //文件长度为零时
MessLabel.Text = "请你选择你要上传的文件";
}
else
{
Byte[] FileByteArray = new Byte[FileLength]; //文件临时储存Byte数组
Stream StreamObject = UpFile.InputStream; //建立数据流对像
//读取文件数据,FileByteArray为数据储存体,0为数据指针位置、FileLnegth为数据长度
StreamObject.Read(FileByteArray,0,FileLength);
//建立SQL Server链接
String SQLStatement = "INSERT INTO Information(标题, 时间, 撰稿人, ImageData, ImageContentType, ImageSize, ImageClass, InvType, 内容) VALUES (@Inf_Title, Getdate(), @Inf_Name, @ImageData, @ImageContentType, @ImageSize, @ImageClass, @InvType, @Inf_Text)";
SqlCommand myCommand = new SqlCommand(SQLStatement,CNN.AOSmithsqlConnection);
myCommand.Parameters.Add("@Inf_Title", SqlDbType.Char,120).Value = Inf_Title; //标题
myCommand.Parameters.Add("@Inf_Name", SqlDbType.VarChar,20).Value = Inf_Name; //撰稿人
myCommand.Parameters.Add("@ImageData",SqlDbType.Binary, FileLength).Value = FileByteArray; //上传文件
myCommand.Parameters.Add("@ImageContentType", SqlDbType.VarChar,50).Value = UpFile.ContentType; //记录文件类型
myCommand.Parameters.Add("@ImageSize", SqlDbType.BigInt,8).Value = UpFile.ContentLength; //记录文件长度,读取时使用
myCommand.Parameters.Add("@ImageClass", SqlDbType.VarChar,10).Value = Session["ImageClass"].ToString();
myCommand.Parameters.Add("@InvType", SqlDbType.Char,20).Value = InvType;
myCommand.Parameters.Add("@Inf_Text", SqlDbType.Text,Inf_TextTextBox.Text.Length).Value = Inf_TextTextBox.Text;
CNN.AOSmithsqlConnection.Open();
myCommand.ExecuteNonQuery();
CNN.AOSmithsqlConnection.Close();
MessLabel.Text = "<p><b>OK!你已经成功上传你的文件</b>";//提示上传成功
BindDatas();
}
}
catch (Exception ex)
{
MessLabel.Text = ex.Message.ToString();
}
}
2.输出
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if (!IsPostBack)
{
String SQLStatement = "SELECT * FROM Information WHERE ImageID = " + Session["ImageID"].ToString().Trim();
SqlCommand myCommand = new SqlCommand(SQLStatement,CNN.AOSmithsqlConnection);
CNN.AOSmithsqlConnection.Open(); SqlDataReader SqlReader = myCommand.ExecuteReader();
SqlReader.Read();
Response.ContentType = (string)SqlReader["ImageContentType"];//设定输出文件类型
//输出图象文件二进制数制
Response.OutputStream.Write((byte[])SqlReader["ImageData"], 0, (int)SqlReader["ImageSize"]);
Response.End();
CNN.AOSmithsqlConnection.Close();
} }