1
안녕에의 PictureBox에 MS 액세스에서 사진을 얻기하지만 지금 내가에 데이터베이스에서 사진을 얻을 수있는 방법을 알고 싶어요 PictureBox은 내가 아래의 코드는, 내 데이터베이스에</p> <p>을 이미지를 저장하는 데 사용한 C#을
도와주세요.
private void button1_Click(object sender, EventArgs e)
{
ofdFoto.ShowDialog();
string i = ofdFoto.FileName.ToString();
pbxFoto.ImageLocation = i;
}
private void button2_Click(object sender, EventArgs e)
{
dbConn.Open();
string querys = "INSERT INTO Fruits (Name, Picture) VALUES ('" + txtName.Text + "','" + ImageToByte(pbxFoto.Image) + "')";
OleDbCommand cd = new OleDbCommand(querys, dbConn);
cd.ExecuteNonQuery();
dbConn.Close();
MessageBox.Show("Picture saved", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
public static byte[] ImageToByte(Image img)
{
ImageConverter converter = new ImageConverter();
return (byte[])converter.ConvertTo(img, typeof(byte[]));
}
나는 이미지 바이트에서 이미지를 변환하는 코드를 가지고 있지만, 방법은 내가의 PictureBox에 그것을 얻을 수 . – ArnoDT
답안을 – Ria
업데이트했습니다. 내 데이터베이스에서 어떻게 사진을 얻을 수 있습니까? – ArnoDT