http://dotnet.aspx.cc/ShowDetail.aspx?id=ECD9AE16-8FF0-4A1C-9B9F-5E8B641CB1B1
解决方案 »
- 请教RegisterStartupScript 导致Jqeury报错的问题
- |zyciis| 查询关键字我添加了按拼音字母查询后如何在查询出来的数据高亮显示 谢谢 急 第二贴
- 急救,如果得到页面来源 用Request.ServerVariables("HTTP_REFERER") 不行
- 急!服务器问题!
- 请帮忙如何吧数据存到文本文件中?
- asp.net中怎么在邮件发送失败后,来得到服务器的返回邮件?高手请进
- 各位,请问全文件索引怎么查含有中文的列!
- 怎么用纯 sj 实现上传文件到服务器上?????
- 怎样把本机变成IIS服务器呢?
- 错在哪里??????
- 请高手指点(小弟很菜,问题很简单)
- 向高手请教:有关DataGrid中数据打印的问题!
Byte[] FileByteArray = new Byte[FileLength]; //图象文件临时储存Byte数组
Stream StreamObject = UpFile.InputStream; //建立数据流对像
//读取图象文件数据,FileByteArray为数据储存体,0为数据指针位置、FileLnegth为数据长度
StreamObject.Read(FileByteArray,0,FileLength);
//建立SQL Server链接
SqlConnection Con = new SqlConnection("Persist Security Info=False;User ID=sa;Initial Catalog=StudyTestData;Data Source=.");
String SqlCmd = "INSERT INTO ImageStore (ImageData, ImageContentType, ImageDescription, ImageSize) VALUES (@Image, @ContentType, @ImageDescription, @ImageSize)";
SqlCommand CmdObj = new SqlCommand(SqlCmd, Con);
CmdObj.Parameters.Add("@Image",SqlDbType.Binary, FileLength).Value = FileByteArray;
CmdObj.Parameters.Add("@ContentType", SqlDbType.VarChar,50).Value = UpFile.ContentType; //记录文件类型
//把其它单表数据记录上传
CmdObj.Parameters.Add("@ImageDescription", SqlDbType.VarChar,200).Value = txtDescription.Text;
//记录文件长度,读取时使用
CmdObj.Parameters.Add("@ImageSize", SqlDbType.BigInt,8).Value = UpFile.ContentLength;
Con.Open();
CmdObj.ExecuteNonQuery();
Con.Close();
txtMessage.Text = "<p><b>OK!你已经成功上传你的图片</b>";
//int ImgID = Convert.ToInt32(Request.QueryString["ImgID"]); //ImgID为图片ID
int ImgID=2;
//建立数据库链接
SqlConnection Con = new SqlConnection("Persist Security Info=False;User ID=sa;Initial Catalog=StudyTestData;Data Source=.");
String SqlCmd = "SELECT * FROM ImageStore WHERE ImageID = @ImageID";
SqlCommand CmdObj = new SqlCommand(SqlCmd, Con);
CmdObj.Parameters.Add("@ImageID", SqlDbType.Int).Value = ImgID;
Con.Open();
SqlDataReader SqlReader = CmdObj.ExecuteReader();
SqlReader.Read();
//Response.ContentType = (string)SqlReader["ImageContentType"];//设定输出文件类型
//输出图象文件二进制数制
Response.OutputStream.Write((byte[])SqlReader["ImageData"], 0, (int)SqlReader["ImageSize"]);
Response.End();
Con.Close();