Error:
No mapping exists from object type System.Windows.Forms.TextBox to a known managed provider native type
I have no idea why is my Visual Studio throwing me this type of error, any sugestions?
Code Snippet :
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);
Change cc.cmd.Parameters.AddWithValue("@d2", txtProductID);
to cc.cmd.Parameters.AddWithValue("@d2", txtProductID.Text);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.