The error is pretty clear:
can't cast system.DBNull type to System.Byte[];
The value returned from your database isn't data - it's a null. That means that either you didn;t insert an image in that column when you saved the row, or it's the wrong column.
Given that you are using
SELECT * FROM
and then accessing your columns numerically starting from 1, that's the most likely.
Never use
SELECT *
- always list the columns you want. That way, changes in the DB column order don't make your app crash, and you don;t fecth information you don;t need.
So try:
SELECT PNM, Desc, Qty, PRC, Picture FROM Stock_tab ...
And use the name of the column to access the DataReader:
if (dr.Read())
{
txtpnm.Text = (string) dr["PNM"];
txtdesc.Text = (string) dr["Desc"];
txtqty.Text = dr["Qty"].ToString();
txtprc.Text = dr.["PRC"].ToString();
byte[] img = (byte[])dr["Picture"];
MemoryStream ms1 = new MemoryStream(img);
pbproduct.Image = Image.FromStream(ms1);
}