这是我的代码(我真的对编码很陌生,这是针对学校项目的):我不知道要这样做,所以当我选择一个项目时,相应的图像就会显示在图片框中。
private void pictureBox1_Click(object sender, EventArgs e)
{
con.Open();
OleDbCommand cmd = new OleDbCommand();
OleDbDataReader readerxx = cmd.ExecuteReader();
if (listBox1.Text == readerxx["Code"].ToString()) //getting errors here
{
cmd.CommandText = "SELECT Code, Working_Example FROM Code WHERE Code = '" + listBox1.Text + "'";
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
byte[] content = (byte[])ds.Tables[0].Rows[0].ItemArray[0];
MemoryStream stream = new MemoryStream(content);
pictureBox1.Image = Image.FromStream(stream);
}
con.Close();
}