http://xml.sz.luohuedu.net/xml/ShowDetail.asp?id=2A5DD7C6-A45A-48AB-A2E8-342A29F17506

解决方案 »

  1.   

    http://dotnet.aspx.cc/ShowDetail.aspx?id=6381BD5F-51F3-4339-4239-1328564A1B2A
      

  2.   

    谢谢,我要保存的图片在Web Service端已经定义了保存为object类型,请问如何显示和上传图片,本系统是C#的Windows应用程序。
      

  3.   

    http://dotnet.aspx.cc/ShowDetail.aspx?id=6381BD5F-51F3-4339-4239-1328564A1B2A
      

  4.   

    //存储图片
    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(); }
    通过测试
      

  5.   

    谢谢各位,但是我的问题是:
    因为Web Service是已经定义好的,Picture参数为Object类型。
    我已经试过将图片转换为二进制数据做参数传入,保存时没发生错误,(如果直接将PictureBox.Image做为Objcet类型保存,发生“保存XML文件错误”)但是独特、
      

  6.   

    但是读取时发现返回的Picture为空,请问如何保存这种Object类型的图片呢?