Image.MemoryStream:参数无效

时间:2016-10-09 16:26:45

标签: c# .net sqlite

当我试图通过组合框检索我的图像时,会显示按摩。 参数无效 我尝试了很多方法,但问题是一样的..

每次我运行下面的代码,我都会得到同样的按摩。

    private void cBoxSearch_SelectedIndexChanged(object sender, EventArgs e)
    {
        try
        {
            con = ConnectionController.GetInstance().GetConnection();
            con.Open();
            com = new SQLiteCommand("SELECT * FROM Stock WHERE ProductName = '" + cBoxSearch.Text + "' ", con);

            myReader = com.ExecuteReader();
            product prod = new product();
            while (myReader.Read())
            {
                prod.proid = myReader[0].ToString();
                prod.prodname = myReader[1].ToString();
                prod.proMdl = myReader[2].ToString();
                prod.serialN = myReader[3].ToString();
                prod.byibgPr = myReader[4].ToString();
                prod.sellPr = myReader[5].ToString();
                prod.quantity = myReader[6].ToString();

                tbxProductID.Text = prod.proid;
                tbxName.Text =prod.prodname;
                tbxModel.Text = prod.proMdl;
                tbxserial.Text = prod.serialN;
                tbxbyingprice.Text = prod.byibgPr;
                tbxSellingprice.Text = prod.sellPr;
                tbxQuantity.Text = prod.quantity;

                prod.imgg = (byte[])(myReader[7] );

                if (prod.imgg == null)
                {
                    pBX.Image = null;

                }
                else
                {
                    MemoryStream mstrm = new MemoryStream(prod.imgg);
                    Bitmap bmp = new Bitmap(mstrm);

                }

            }
            con.Close();
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
            com.Cancel();
            con.Close();
        }

enter image description here

1 个答案:

答案 0 :(得分:0)

尝试咨询这个问题:

convert binary to bitmap using memory stream

此外,它可能取决于查询的第8列的DBType。

相关问题