Read a picture from Access DB into PictureBox
I have been trying to read a picture saved in Access DB as a OLE object in a PictureBox in a C# windows Application.

The code that does this is presented below:

            string connString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Rajesh\SampleDB_2003.mdb;";
            OleDbConnection oConn = new OleDbConnection(connString);
            oConn.Open();
            string commandString = "select * from employee where id = " + id + "";
            OleDbCommand oCmd = new OleDbCommand(commandString, oConn);
            OleDbDataReader oReader = oCmd.ExecuteReader(CommandBehavior.SequentialAccess);

            while (oReader.Read())
            {
                txtID.Text = ((int)oReader.GetValue(0)).ToString();
                txtName.Text = (string)oReader.GetValue(1);
                txtAge.Text = ((int)oReader.GetValue(2)).ToString();
                txtType.Text = (string)oReader.GetValue(3);
                byte[] imageBytes = (byte[])oReader.GetValue(4);

                MemoryStream ms = new MemoryStream();
                ms.Write(imageBytes, 0, imageBytes.Length);
                Bitmap bmp = new Bitmap(ms);
                pbPassport.Image = bmp;
            }

When I execute the above code, an 'Parameter is not valid' exception is thrown at the line:

    Bitmap bmp = new Bitmap(ms)

From the exception message, it is clear that 'ms' is in a format that is not recognisable. Any suggestion to get past this?
Read a picture from Access DB into PictureBox
===

I have been trying to read a picture saved in Access DB as a OLE object in a PictureBox in a C# windows Application.

The code that does this is presented below:

            string connString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Rajesh\SampleDB_2003.mdb;";
            OleDbConnection oConn = new OleDbConnection(connString);
            oConn.Open();
            string commandString = "select * from employee where id = " + id + "";
            OleDbCommand oCmd = new OleDbCommand(commandString, oConn);
            OleDbDataReader oReader = oCmd.ExecuteReader(CommandBehavior.SequentialAccess);

            while (oReader.Read())
            {
                txtID.Text = ((int)oReader.GetValue(0)).ToString();
                txtName.Text = (string)oReader.GetValue(1);
                txtAge.Text = ((int)oReader.GetValue(2)).ToString();
                txtType.Text = (string)oReader.GetValue(3);
                byte[] imageBytes = (byte[])oReader.GetValue(4);

                MemoryStream ms = new MemoryStream();
                ms.Write(imageBytes, 0, imageBytes.Length);
                Bitmap bmp = new Bitmap(ms);
                pbPassport.Image = bmp;
            }

When I execute the above code, an 'Parameter is not valid' exception is thrown at the line:

    Bitmap bmp = new Bitmap(ms)

From the exception message, it is clear that 'ms' is in a format that is not recognisable. Any suggestion to get past this?