[英]Error CS7036 with newly added code
Why am I getting this error... 为什么我会收到此错误...
I have a class called Product and this is part of the code: 我有一个名为Product的类,这是代码的一部分:
public void insertProduct(int cid, string name, string price, byte[] image, int quantity, string desc, int company, int compid)
{
DB db = new DB();
db.openConnection();
SqlParameter[] parameters = new SqlParameter[8];
parameters[0] = new SqlParameter("@c_id", SqlDbType.Int);
parameters[0].Value = cid;
parameters[1] = new SqlParameter("@p_name", SqlDbType.VarChar, 50);
parameters[1].Value = name;
parameters[2] = new SqlParameter("@s_qty", SqlDbType.Int);
parameters[2].Value = quantity;
parameters[3] = new SqlParameter("@price", SqlDbType.VarChar, 50);
parameters[3].Value = price;
parameters[4] = new SqlParameter("@desc", SqlDbType.VarChar);
parameters[4].Value = desc;
parameters[5] = new SqlParameter("@img", SqlDbType.Image);
parameters[5].Value = image;
parameters[6] = new SqlParameter("@comp", SqlDbType.Int);
parameters[6].Value = company;
parameters[7] = new SqlParameter("@comp_id", SqlDbType.Int);
parameters[7].Value = compid;
db.setData("spr_insert_product", parameters);
db.closeConnection();
}
I call this class from the Form "Add" Button 我从“添加”按钮中调用该类
private void BTN_ADD_Click(object sender, EventArgs e)
{
if (TB_NAME.Text == string.Empty)
{
MessageBox.Show("Enter The Product Name", "Empty Data", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
if (TB_PRICE.Text == string.Empty && TB_QUANTITY.Text == string.Empty)
{
MessageBox.Show("Quantity and Price Can't Be Empty | But Can Be Equal To 0", "Empty Data", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else if (PB_BROWSE_IMAGE.Image == null)
{
MessageBox.Show("No Image Selected", "No Image", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
MemoryStream ms = new MemoryStream();
PB_BROWSE_IMAGE.Image.Save(ms, PB_BROWSE_IMAGE.Image.RawFormat);
byte[] image = ms.ToArray();
product.insertProduct(Convert.ToInt32(COMBO_CATEGORIES.SelectedValue), TB_NAME.Text,
TB_PRICE.Text, image, Convert.ToInt32(TB_QUANTITY.Text), TB_DESCRIPTION.Text);
MessageBox.Show("New Product Inserted Successfully", "New Product", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
Under this code at the very end on line: 在此代码的最后一行:
product.insertProduct(
is where I get this error and I can't figure out why? 是我得到此错误的地方,我不知道为什么? Just for a reference... Everything was working fine until I added code to the method:
仅供参考...一切正常,直到我向该方法添加代码:
int company, int compid
to associate with 2 more columns added to the DB and also code: 与添加到数据库中的另外2列关联,并进行编码:
parameters[6] = new SqlParameter("@comp", SqlDbType.Int);
parameters[6].Value = company;
parameters[7] = new SqlParameter("@comp_id", SqlDbType.Int);
parameters[7].Value = compid;
If I take this newly added code, I am not getting an error. 如果使用此新添加的代码,则不会出错。 Can anyone spot what is wrong here and how to fix it?
谁能在这里发现问题所在以及如何解决?
Thank you Piro for your comment... Late night and I didn't see it: Here is the code that did it: 谢谢Piro的评论...深夜,我没看到它:这是完成它的代码:
product.insertProduct(Convert.ToInt32(COMBO_CATEGORIES.SelectedValue), TB_NAME.Text,
TB_PRICE.Text, image, Convert.ToInt32(TB_QUANTITY.Text), TB_DESCRIPTION.Text, TB_COMPANY.Text, TB_COMP_ID.Text);
MessageBox.Show("New Product Inserted Successfully", "New Product", MessageBoxButtons.OK, MessageBoxIcon.Information);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.