私は画像ボックスを持っています。画像ボックス内の画像は静的な画像です。リソースフォルダからイメージをロードしています。私は画像ボックスから静止画像を読んでデータベースに格納することができません。ここに私のコードです。画像ボックスの画像をデータベースに保存
private void btnOk_Click(object sender, EventArgs e)
{
Image votingBackgroundImage = pictureBox5.Image;
Bitmap votingBackgroundBitmap = new Bitmap(votingBackgroundImage);
Image votingImage = (Image)votingBackgroundBitmap;
var maxheight = (votingImage.Height * 3) + 2;
var maxwidth = votingImage.Width * 2;
if (maxheight == 227 && maxwidth == 720)
{
System.IO.MemoryStream defaultImageStream = new System.IO.MemoryStream();
Bitmap NewImage =new Bitmap(votingImage,new Size(720,227));
Image b = (Image)NewImage;
b.Save(defaultImageStream, System.Drawing.Imaging.ImageFormat.Bmp);
defaultImageData = new byte[defaultImageStream.Length];
}
}
クエリは、私は、データベース内の画像を追加するために使用:
String MyString1=string.format("insert into question_table(background_image) Values(@background_image)");
com = new SqlCommand(MyString1, myConnection);
com.Parameters.Add("@background_image", SqlDbType.Image).Value = defaultImageData;
com.ExecuteNonQuery();
私は0 x000000として値を格納database.It SQLでこれをチェックすると...