0
C# winforms에서 PictureBox로 이미지를 검색하는 방법은 무엇입니까? 이 코드를 시도했지만 매개 변수가 내 비트 맵에서 유효하지 않습니다라는 인수 예외가 있습니다.C# winforms의 데이터베이스에서 그림 상자로 이미지 검색
byte[] image = (byte[])command.ExecuteScalar();
TypeConverter tc = TypeDescriptor.GetConverter(typeof(Bitmap));
Bitmap bitmap = (Bitmap)tc.ConvertFrom(image);
또는 :이 사용
con = new SqlConnection(strConnection);
MemoryStream stream = new MemoryStream();
con.Open();
SqlCommand command = new SqlCommand(
"select companyLogo from companyDetailsTbl where companyId = 1", con);
byte[] image = (byte[])command.ExecuteScalar();
stream.Write(image, 0, image.Length);
con.Close();
Bitmap bitmap = new Bitmap(stream); //This is the error
return bitmap;