C# Visual Studio引发的有关TextBox对象的异常

C# Visual Studio引发的有关TextBox对象的异常,c#,sql,winforms,C#,Sql,Winforms,错误: 不存在从对象类型System.Windows.Forms.TextBox到已知托管提供程序本机类型的映射 我不知道为什么我的VisualStudio会给我这种类型的错误,有什么建议吗 代码片段: MemoryStream ms = new MemoryStream(); Bitmap bmpImage = new Bitmap(pictureBox1.Image); bmpImage.Save(ms, System.

错误:

不存在从对象类型System.Windows.Forms.TextBox到已知托管提供程序本机类型的映射

我不知道为什么我的VisualStudio会给我这种类型的错误,有什么建议吗

代码片段:

            MemoryStream ms = new MemoryStream();
            Bitmap bmpImage = new Bitmap(pictureBox1.Image);
            bmpImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
            byte[] data = ms.GetBuffer();
            cc.con = new SqlConnection(cs.DBConn);
            cc.con.Open();
            string cb = "insert into Product(P_ID,ProductID,ProductName,SubCategoryID,Features,Price,VAT,ST,Discount,Photo) VALUES (@d1,@d2,@d3,@d4,@d5,@d6,@d7,@d8,@d9,@d10)";
            cc.cmd = new SqlCommand(cb);
            cc.cmd.Connection = cc.con;
            cc.cmd.Parameters.AddWithValue("@d1", txtID.Text);
            cc.cmd.Parameters.AddWithValue("@d2", txtProductID);
            cc.cmd.Parameters.AddWithValue("@d3", txtProductName.Text);
            cc.cmd.Parameters.AddWithValue("@d4", txtSubCategoryID.Text);
            cc.cmd.Parameters.AddWithValue("@d5", txtFeatures.Text);
            cc.cmd.Parameters.AddWithValue("@d6", txtPrice.Text);
            cc.cmd.Parameters.AddWithValue("@d7", txtVAT.Text);
            cc.cmd.Parameters.AddWithValue("@d8", txtServiceTax.Text);
            cc.cmd.Parameters.AddWithValue("@d9", txtDiscount.Text);
            cc.cmd.Parameters.AddWithValue("@d10",data);
            cc.cmd.ExecuteReader();
            cc.con.Close();
            st1 = lblUser.Text;
            st2 = "adicionou um produto '" + txtProductName.Text + "'";
            cf.LogFunc(st1,System.DateTime.Now,st2);

更改
cc.cmd.Parameters.AddWithValue(“@d2”,txtProductID)
to
cc.cmd.Parameters.AddWithValue(“@d2”,txtProductID.Text)

哪一行抛出了错误?@Sparrow我认为这是关于productID没有与.Text事件关联,所以是的,我将检查它并给出反馈。