0
 string constring = "server=localhost;uid=root;" + "pwd=12345;database=products;";
            string query = "SELECT prd_items_image FROM products.prd_items where prd_items_id=5";
            MySqlConnection condatabase = new MySqlConnection(constring);
            MySqlCommand cmddatabase = new MySqlCommand(query, condatabase);
            MySqlDataReader myreader;
            try
            {
                condatabase.Open();
                myreader = cmddatabase.ExecuteReader();
                while (myreader.Read())
                {
                    byte[] imgg = (byte[])(myreader["prd_items_image"]);
                    if (imgg == null)
                        box.Image = null;
                    else
                    {
                        MemoryStream mstream = new MemoryStream(imgg);
                       box.Image = System.Drawing.Image.FromStream(mstream);
                    }
                }

我在 if 条件下遇到错误,

box.Image=null andbox.Image = System.Drawing.Image.FromStream(mstream);

在这两种情况下,我在 Image 上遇到错误。所以请检查一次。如果您有任何其他代码,请在需要时提供给我。

4

0 回答 0