我的应用程序是C/S结构的,数据库中某张表有一个image字段,现在我定义了一个结构体包含了这张表的结构,譬如:
class Car
{
string price
int distance
string name
.....
}
如何在程序中建立相对于数据库中image字段的变量
byte[] picture
可以吗?
如果是这样,我怎样将已经显示在DataGridView中的一条记录(其中包含image字段的内容)提取出来,存入我的变量中啊?
可能各位要考虑下序列化问题,因为我是要把服务器端的数据传入客户端。
class Car
{
string price
int distance
string name
.....
}
如何在程序中建立相对于数据库中image字段的变量
byte[] picture
可以吗?
如果是这样,我怎样将已经显示在DataGridView中的一条记录(其中包含image字段的内容)提取出来,存入我的变量中啊?
可能各位要考虑下序列化问题,因为我是要把服务器端的数据传入客户端。
解决方案 »
- Socket 955 异常 通常是啥原因?
- 类成员:internal与protected类型有何区别呢?为何说可以合并使用?
- winform读卡信息
- 请问如何让表格(SourceGrid)的效率像Excel一样
- froms验证
- 图表相关,MSCHART相关,C#,曲线图绘制及缩放,问题内详
- ComboBox怎么设置默认选择项和不能输入只能选择里面的内容??
- 『请教』有读取属性文件中的key和value的类吗?要自己写吗?
- 用C#写Web程序时,怎么把Mapx控件放入页面?
- 【新人求救】更新的时候 当传递具有新行的 DataRow 集合时,Update 要求有效的 InsertComman
- 求检查是否包含非法词语的正则写法,是否比用indexof这种方法快......
- 关闭WinForm程序时,程序不会自动结束,求教!
public Image getImage(object o)
{
Image img = null;
byte[] bts = o as byte[];
if (bts != null)
{
MemoryStream ms = null;
try
{
ms = new MemoryStream(bts, 0, bts.Length);
{
img = Image.FromStream(ms, true);
}
}
catch { }
finally
{
if (ms != null)
{
ms.Close();
}
}
}
return img;
}
public Image ConvertToImage(object o)
{
if (o is byte[])
{
ImageConverter imc = new ImageConverter();
Image _img = imc.ConvertFrom(null, System.Globalization.CultureInfo.CurrentCulture, o) as Image;
if (_img != null)
{
Rectangle imgRect = getImgPaintRect(rect, _img.Width, _img.Height, col.m_ValueFormat.Alignment);
g.DrawImage(_img, imgRect);
_img.Dispose();
_img = null;
return;
}
}
return null;
}
请赐教