请问如何显示和上传System.Object类型的图片?? http://xml.sz.luohuedu.net/xml/ShowDetail.asp?id=2A5DD7C6-A45A-48AB-A2E8-342A29F17506 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://dotnet.aspx.cc/ShowDetail.aspx?id=6381BD5F-51F3-4339-4239-1328564A1B2A 谢谢,我要保存的图片在Web Service端已经定义了保存为object类型,请问如何显示和上传图片,本系统是C#的Windows应用程序。 http://dotnet.aspx.cc/ShowDetail.aspx?id=6381BD5F-51F3-4339-4239-1328564A1B2A //存储图片 private void ins_pic_sql() { System.Data.SqlClient.SqlConnection myconn=new SqlConnection("User Id=sa;password=;Data Source=GONGJ;initial catalog=test_1"); myconn.Open(); SqlCommand comm=new SqlCommand(); comm.Connection=myconn;// comm.CommandType=CommandType.StoredProcedure; comm.CommandText="insert into userdetail(userid,username,userpict) values(@userid,@username,@userpict)"; System.IO.MemoryStream mstream=new System.IO.MemoryStream(); pictBox1.Image.Save(mstream,System.Drawing.Imaging.ImageFormat.Jpeg); byte[] barray=new byte[Convert.ToInt32(mstream.Length)]; mstream.Read(barray,0,Convert.ToInt32(mstream.Length)); SqlParameter sp=new SqlParameter("@userpict",System.Data.SqlDbType.Image,Convert.ToInt32(mstream.Length)); sp.Value=barray; comm.Parameters.Add(sp); sp=new SqlParameter("@userid",System.Data.SqlDbType.Int); sp.Value=1; comm.Parameters.Add(sp); sp=new SqlParameter("@username",System.Data.SqlDbType.VarChar); sp.Value=pictBox1.Image.GetType().ToString(); comm.Parameters.Add(sp); comm.ExecuteNonQuery(); myconn.Close(); }通过测试 谢谢各位,但是我的问题是:因为Web Service是已经定义好的,Picture参数为Object类型。我已经试过将图片转换为二进制数据做参数传入,保存时没发生错误,(如果直接将PictureBox.Image做为Objcet类型保存,发生“保存XML文件错误”)但是独特、 但是读取时发现返回的Picture为空,请问如何保存这种Object类型的图片呢? 【求助】如何划出一条线段,且可以对其选中,拉伸和旋转 请教,如何判断背景色? 怎么上传上去出错呀,请各位帮帮忙,在线等。 dataGrid问题 DataGrid问题,很小! “GenerateResource”任务意外失败。 请高手赐教:如何在winform 窗体中嵌excel(C#) 谁能提供下toolStripContainer的学习资料 在线等一段XML解析代码 C# Combobox 当下拉列表关闭时,需要展示输入的数据,不选中第一个匹配的数据 寻.无刷新聊天室示例代码(asp.net的) 散分:哪里有winform的数据库项目源码下载?
private void ins_pic_sql()
{
System.Data.SqlClient.SqlConnection myconn=new SqlConnection("User Id=sa;password=;Data Source=GONGJ;initial catalog=test_1");
myconn.Open();
SqlCommand comm=new SqlCommand();
comm.Connection=myconn;
// comm.CommandType=CommandType.StoredProcedure;
comm.CommandText="insert into userdetail(userid,username,userpict) values(@userid,@username,@userpict)";
System.IO.MemoryStream mstream=new System.IO.MemoryStream();
pictBox1.Image.Save(mstream,System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] barray=new byte[Convert.ToInt32(mstream.Length)];
mstream.Read(barray,0,Convert.ToInt32(mstream.Length)); SqlParameter sp=new SqlParameter("@userpict",System.Data.SqlDbType.Image,Convert.ToInt32(mstream.Length));
sp.Value=barray;
comm.Parameters.Add(sp); sp=new SqlParameter("@userid",System.Data.SqlDbType.Int);
sp.Value=1;
comm.Parameters.Add(sp); sp=new SqlParameter("@username",System.Data.SqlDbType.VarChar);
sp.Value=pictBox1.Image.GetType().ToString();
comm.Parameters.Add(sp); comm.ExecuteNonQuery();
myconn.Close(); }
通过测试
因为Web Service是已经定义好的,Picture参数为Object类型。
我已经试过将图片转换为二进制数据做参数传入,保存时没发生错误,(如果直接将PictureBox.Image做为Objcet类型保存,发生“保存XML文件错误”)但是独特、