当前位置:首页 » 操作系统 » img数据库

img数据库

发布时间: 2023-08-29 00:13:53

数据库以img存储,如何读取图片

直接使用企业管理器好像没有办法操作吧,通过软件或自己做个小软件读取。

#region //读取数据库中图片到内存.并显示
public void LoadToMemoryAndDisable(string serverAdress, string database)
{
//读取数据库中图片到内存.并显示
SqlConnection conn = new SqlConnection("server=" + serverAdress + ";integrated security = sspi;database = " + database);
SqlCommand cmd = new SqlCommand("select * from imgtable where imgname like '%bmp%'", conn);
conn.Open();
SqlDataReader dr;
try
{
dr = cmd.ExecuteReader();
dr.Read();
System.Data.SqlTypes.SqlBinary sb = dr.GetSqlBinary(2);
//或byte[] imageData = (byte[])dr[2];
MemoryStream ms = new MemoryStream(sb.Value);//在内存中操作图片数据
Bitmap bmp = new Bitmap(Bitmap.FromStream(ms));
this.pictureBox1.Image = bmp;
dr.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
conn.Close();
}
}
#endregion

热点内容
服务器和电脑主机 发布:2025-07-01 17:11:00 浏览:855
云服务器解压文件闪退 发布:2025-07-01 17:05:01 浏览:222
android换颜色 发布:2025-07-01 17:00:21 浏览:284
声音数据存储量计算公式 发布:2025-07-01 16:57:45 浏览:124
微信号加密码登录什么意思 发布:2025-07-01 16:53:15 浏览:181
java8的接口 发布:2025-07-01 16:53:14 浏览:779
hxd压缩 发布:2025-07-01 16:50:10 浏览:426
app页面源码 发布:2025-07-01 16:39:04 浏览:85
安卓游戏语音包在哪里 发布:2025-07-01 16:11:41 浏览:76
走心机编程教学 发布:2025-07-01 15:34:30 浏览:222