如何将数据库中image类型字段的图片显示到页面的上的Image控件上?虽然用Response.BinaryWrite((byte[])users.PhotoData)也可以显示但不方便控制图片大小。
解决方案 »
- 求MDi下mdi子窗体只能运行一次的代码
- remoting无法连接服务器
- 关于一个socket的问题!!
- C#中有类似于Java中的package语句用来打包类的吗?
- combobox绑定数据源的问题
- 如何去关闭一个From的实例?
- 难题:怎么用代码动态探测遍例列出C# Class里的各个可访问的参数名和值?
- 关于asp.net gridview中textbox触发问题
- 请问大家帮忙看看我这个web.config问题,谢谢
- 用Apache可不可以运行C#(web form)
- 关于dataGridView1_CellLeave 事件!
- winForm 如何使dataGridView最后一行合计不参与排序
再用<img src />显示即可。
string ConnectionString=@"..."
string SQL="select * from 文件";
SqlConnection conn=new OleDbConnection(ConnectionString);
SqlCommand cmd=conn.CreateCommand();
cmd.CommandText=SQL;
conn.Open();
SqlDataReader dr=cmd.ExecuteReader(); if(dr.Read())
{
string strFile=string.Empty;
strFile=dr.GetString(1);
byte[] by=(byte[])dr.GetValue(2); FileStream fs=File.Open(strFile,FileMode.Create,FileAccess.Write);
fs.Write(by,0,by.Length);
fs.Close();
MessageBox.Show("读取成功!");
}
dr.Close();
conn.Close();