简体   繁体   English

错误CS7036,带有新添加的代码

[英]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.

相关问题 错误 CS7036 没有给出与所需形式参数相对应的参数 - Error CS7036 There is no argument given that corresponds to the required formal parameter 我如何捕捉CS7036错误 - How do i catch the CS7036 error Visual Studio c# 错误 CS7036 方法调用 - Visual Studio c# Error CS7036 Method Call CS7036 C# 如何解决错误按钮 onclick - CS7036 C# How to solve error button onclick 错误 CS7036:没有给出与所需形式参数“播放器”相对应的参数无法找出代码的问题? - error CS7036: There is no argument given that corresponds to the required formal parameter 'player' can't figure out the issue with the code? 在计算器的方法之间传递变量时出现 CS7036 错误(来自我在互联网上找到的代码测试)) - Getting a CS7036 error when passing variables between methods for a calculator (from a code test I found on the internet)) C# 中的 Inheritance 问题:CS7036 - Inheritance Issue in C# : CS7036 C# - 当我尝试创建构造函数时,出现 CS7036 错误 - C# - When i try to create constructor, i get CS7036 error 错误 CS7036:没有给出与 Lärare.Lärare 所需的形式参数“namn”相对应的参数 - Error CS7036: There is no argument given that corresponds to the required formal parameter 'namn' of Lärare.Lärare 我收到错误 CS7036,我不知道如何解决它 - I get error CS7036 and I am clueless on how to solve it
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM