可能我没说清楚,我在我在SQL Server 2000中建了一个image类型的字段(photo)用来存储个人照片,做了一个存储过程,然后在类中的方法test加入一句
SqlComm.Parameters .Add ("@Photo",SqlDbType.Image ,16).Value=Photo;
其中SqlCommand SqlComm,@Photo在存储过程中定义为Image ,Byte Photo在winform内加了一个image控件,名为Picture,写入如下代码:
Photo=Convert.ToByte (Picture.Image.GetType () );其中Byte Photo,
但是我将Photo传入到类中的方法test中出错,是类型转换错误,请问该如何定义Photo类型,
编译时是通过的,但执行时就出错,各位帮我一把吧
SqlComm.Parameters .Add ("@Photo",SqlDbType.Image ,16).Value=Photo;
其中SqlCommand SqlComm,@Photo在存储过程中定义为Image ,Byte Photo在winform内加了一个image控件,名为Picture,写入如下代码:
Photo=Convert.ToByte (Picture.Image.GetType () );其中Byte Photo,
但是我将Photo传入到类中的方法test中出错,是类型转换错误,请问该如何定义Photo类型,
编译时是通过的,但执行时就出错,各位帮我一把吧
解决方案 »
- 请教大家:服务器端管理n多个客户端
- 请问谁有the Google Web APIs Developer's Kit
- 怎样同步两个SQL SERVER的数据?
- 两幅图片合成的问题
- 关于 VS 2005 Beta 2 中添加新项的问题
- 高手请进,如何把stream保存到文件夹中??
- 求asp.net C#如何检测服务器的CPU个数
- <<c#入门经典>>里的两个问题
- c#创建word时如何设置图片插入到指定文字后
- 有没有人知道如何在WinForm中画表格,并且能够用鼠标拖动来调整表格的框度和高度,而且能在表格中显示文字???
- c#里面连接数据库有几种方式?他们有怎样的优缺点
- 请SQL高手看看一个很有技术含量、但又简单的SQL查询语句,不胜感激!
{
//將數據表中的image讀取到picturebox
int nowPosition=this.BindingContext[this.dataset1,"customers"].Position ;
if (!(Convert.IsDBNull(this.dataset1.Tables["customers"].Rows[nowPosition] ["嘜頭"])))
{
// Open a stream for the image and write the bytes into it
byte[] byttrade=(byte[])this.dataset1.Tables["customers"].Rows[nowPosition]["嘜頭"];
System.IO.MemoryStream stmtrade=new MemoryStream(byttrade);
stmtrade.Write(byttrade,0,byttrade.Length);
// Create a bitmap from the stream
Bitmap bmp=new Bitmap(stmtrade);
// Check for scaling and assign the bitmap to the Picturebox
if (bmp.Width >264 && bmp.Height >184)
{
Bitmap bmp1=new Bitmap(bmp,new Size(264,184));
this.pictureBox1.Image=bmp1;
}
else
{this.pictureBox1.Image =bmp;}
}
else
{
this.pictureBox1.Image=null;
}
}
byte[] Data = new Byte[File.ContentLength];
//force the control to load data in array
File.InputStream.Read(Data,0,File.ContentLength);
//Create procedure parameter
object[] obj = new object[1]; obj[0] = Data;//Execute the procedure with Microsoft.ApplicationBlocks.Data
//Simple procedure
/*CREATE PROCEDURE sp_img(@img image) ASinsert into tb_img values(@img)*///record data
SqlHelper.ExecuteNonQuery(connectionString,"sp_img",obj);