关于显示图片 你可以这样参考一下:将数据库中的图片(s)读取 存放在 byte[] 数组中,通过timer来循环显示! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这很简单!eg: 将要放入数据库中的图像文件以流式读入 假设你要读入的文件位置是c:\images\mypic.jpg; FileStrem fs=new FileStream(@"c:\images\mypic.jpg",FileMode.Open,FileAccess.Read); BinaryReader br=new BinaryReader(fs); byte[] imageData=new byte[fs.length]; imageData=br.ReadBytes[fs.length]; 插入时最好用存储过程 ge: create procedure insertPhoto @id int, @image image=null as insert into tableImage values(@id,@iamge) return SqlCommand sqlComad=new SqlCommand(sqlConnnection);sqlComad.CommandType=CommandType.StoredProcedure;sqlComad.CommandText=insertPhoto; SqlParameter im=new SqlParameter();im.Name=@"@iamge"; if(imageData==null) im.Value=nullelse im.Value=imageData;读出时这样做就OK了 SqlDataReader dr=sqlComamd.ExecuteRead();while(dr.Read()){ try { byte[] image=(byte[])dr.GetValue(1); System.IO.MemoryStream ms=new System.IO.MemoryStream(image); Bitmap bmp=new Bitmap(ms); myPicture.Image=bmp; } catch { myPicture.Image=bmp; } }主要代码就这些啦,仔细看一下,一定要将图像文件转化为字节数组,读出最好用内存文件流,不过如果文件太大的话,就不行了不过我认为存路径比较好,你去参考一下其它的书 这是asp.net : http://www.aspcool.com/lanmu/browse1.asp?ID=830&bbsuser=asp C#利用windows api 取ftp服务器上的文件 大大帮忙,控件上的图形闪烁的厉害啊 急救 mschart 这算是C#的BUG吗 有没有Dataset中的Table的添加、删除事件? 如何使用Process相关信息取得进程的物理路径? 关于listbox的问题 C#群 关于zlib.dll解压缩的实现 通过winform操作网页内容,出现错误:passport未定义 做视频会议系统从哪儿开始入手阿? 兼职的来啊!
eg:
将要放入数据库中的图像文件以流式读入
假设你要读入的文件位置是c:\images\mypic.jpg;
FileStrem fs=new FileStream(@"c:\images\mypic.jpg",FileMode.Open,FileAccess.Read);
BinaryReader br=new BinaryReader(fs);
byte[] imageData=new byte[fs.length];
imageData=br.ReadBytes[fs.length];
插入时最好用存储过程
ge:
create procedure insertPhoto
@id int,
@image image=null
as
insert into tableImage values(@id,@iamge)
return
SqlCommand sqlComad=new SqlCommand(sqlConnnection);
sqlComad.CommandType=CommandType.StoredProcedure;
sqlComad.CommandText=insertPhoto;
SqlParameter im=new SqlParameter();
im.Name=@"@iamge";
if(imageData==null)
im.Value=null
else
im.Value=imageData;
读出时这样做就OK了
SqlDataReader dr=sqlComamd.ExecuteRead();
while(dr.Read())
{
try
{
byte[] image=(byte[])dr.GetValue(1);
System.IO.MemoryStream ms=new System.IO.MemoryStream(image);
Bitmap bmp=new Bitmap(ms);
myPicture.Image=bmp;
}
catch
{ myPicture.Image=bmp;
}
}
主要代码就这些啦,仔细看一下,一定要将图像文件转化为字节数组,
读出最好用内存文件流,不过如果文件太大的话,就不行了
不过我认为存路径比较好,
你去参考一下其它的书