繁体   English   中英

Visual Studio对TextBox对象抛出的异常

[英]Exception thrown by Visual Studio regarding TextBox object

错误:

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

我不知道为什么我的Visual Studio会抛出此类错误,任何提示?

代码段:

            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); cc.cmd.Parameters.AddWithValue("@d2", txtProductID.Text);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM