<asp:Image ImageUrl="Image.aspx?id=123" runat=server />and see how to write Image.aspx inRetrieving Images from SqlServer in ASP .NET
http://authors.aspalliance.com/das/readimage.aspx
http://authors.aspalliance.com/das/readimage.aspx
解决方案 »
- 首页打开比较慢(不是网站第一次打开那种慢)
- 急!! repeater问题
- 刷新不了下拉列表
- 请问asp.net(c#)的DropDownList是怎样用的?(绑定了SQL)
- Web页面数据导出EXcel的问题?
- CSS样式问题 在线等
- 求助,在一个项目中用了TREEVIEW控件,现在要布置到一个买来的空间上,但是空间管理员不同意在人家的IIS里面配那个树控件的夹子,怎么办
- asp.net能否上传文件夹下所有文件?
- 怎么访问域名/文件夹名称跳转到另个页面或者cs文件
- 帮,怎么修改更新更不了的错误
- 如何在javascript脚本函数中用字符变量调用对象属性呢?
- 多了个三角散分!!!!!!!!为了谢谢陕北吴旗娃大哥和帮助过我的各位兄弟!!!!!!!!
private void Button1_Click(object sender, System.EventArgs e)
{
HttpPostedFile UpFile = UP_FILE.PostedFile; //HttpPostedFile对象,用于读取图象文件属性
FileLength = UpFile.ContentLength; //记录文件长度
try
{
if (FileLength == 0)
{ //文件长度为零时
txtMessage.Text = "<b>请你选择你要上传的文件</b>";
}
else
{
Byte[] FileByteArray = new Byte[FileLength]; //图象文件临时储存Byte数组
Stream StreamObject = UpFile.InputStream; //建立数据流对像
//读取图象文件数据,FileByteArray为数据储存体,0为数据指针位置、FileLnegth为数据长度
StreamObject.Read(FileByteArray,0,FileLength);
String cmdInsert = "INSERT INTO ImageStore (ImageData, ImageContentType, ImageDescription, ImageSize) VALUES (@Image, @ContentType, @ImageDescription, @ImageSize)";
SqlCommand CmdObj = new SqlCommand(cmdInsert,sqlConnection1);
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;
sqlConnection1.Open();
CmdObj.ExecuteNonQuery();
sqlConnection1.Close();
txtMessage.Text = "<p><b>OK!你已经成功上传你的图片</b>";//提示上传成功
}
}
catch (Exception ex)
{
txtMessage.Text = ex.Message.ToString();
}
}
我想用c#在asp.net中,用Image服务器控件显示我在数据库存储的图片!谢谢!!
Uploading and retrieving images from SQL Server
http://www.dotnetbips.com/displayarticle.aspx?id=60