title: retrieve image from MS Access
body: <p>I want to retrieve an image from ms access database for showing in a PictureBox with this code 
  my code is like this:</p>
  
  <pre><code>private void button1_Click(object sender, EventArgs e)
      {
          OleDbConnection myConnection = new OleDbConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
  
          myConnection.Open();
          OleDbCommand cmd = new OleDbCommand("select * from [Images] where ID=1", myConnection);
          OleDbDataAdapter da = new OleDbDataAdapter(cmd);
          DataTable dt = new DataTable();
          da.Fill(dt);
  
          if (dt.Rows.Count &gt; 0)
          {
              if (dt.Rows[0]["AImage"] != DBNull.Value)
              {
                  pictureBox.Image = ByteArrayToImage((Byte[])dt.Rows[0]["AImage"]);
              }
          }
          myConnection.Close();   
  
      }
  
      Bitmap ByteArrayToImage(byte[] b)
      {
          MemoryStream ms = new MemoryStream();
          byte[] pData = b;
          ms.Write(pData, 0, Convert.ToInt32(pData.Length));
          Bitmap bm = new Bitmap(ms, false);
          ms.Dispose();
          return bm;
      }
  </code></pre>
  
  <p>but there is an error like:"Parameter is not valid." for <code>Bitmap bm = new Bitmap(ms, false);
  </code>
  I don't know why? </p>