C
Cz
Value does not fall within the expected range.
I got this exception when i try to convert byte array back to image
here is my code :
pic = pub.getPicture("1111111111111")
Dim newImage As Image
Dim ms2 As MemoryStream = New MemoryStream(pic, 0, pic.Length)
ms2.Write(pic, 0, pic.Length)
p.Image = New Bitmap(ms2)
And function getPicture do just read image from sql server2005
here is that code :
public byte[] getPicture(String isbn)
{
byte[] pic;
SqlConnection conn = new SqlConnection(connString);
conn.Open();
sqlCmd = "SELECT book_image FROM book WHERE book_isbn = '" + isbn + "'";
SqlCommand picCmd = new SqlCommand(sqlCmd,conn);
pic = (byte[])picCmd.ExecuteScalar();
conn.Close();
picCmd.Dispose();
return pic;
}
Thank all of you guys for any helps
I got this exception when i try to convert byte array back to image
here is my code :
pic = pub.getPicture("1111111111111")
Dim newImage As Image
Dim ms2 As MemoryStream = New MemoryStream(pic, 0, pic.Length)
ms2.Write(pic, 0, pic.Length)
p.Image = New Bitmap(ms2)
And function getPicture do just read image from sql server2005
here is that code :
public byte[] getPicture(String isbn)
{
byte[] pic;
SqlConnection conn = new SqlConnection(connString);
conn.Open();
sqlCmd = "SELECT book_image FROM book WHERE book_isbn = '" + isbn + "'";
SqlCommand picCmd = new SqlCommand(sqlCmd,conn);
pic = (byte[])picCmd.ExecuteScalar();
conn.Close();
picCmd.Dispose();
return pic;
}
Thank all of you guys for any helps