简体   繁体   English

此代码返回一个错误,指出“没有为一个或多个必需参数提供值”

[英]this code returns an error that says " No value given for one or more required parameters"

private void button9_Click(object sender, EventArgs e)
{
    clss.Connect();
    clss.search("select * from Employee E, AssetAllocation A WHERE E.EmployeeID=6 and A.EmployeeID=6");
    //, where E.EmployeeID=" + textBox12.Text + " and A.EmployeeID=" + textBox12.Text + "");
    while (clss.reader.Read())
    {
        textBox11.Text = clss.reader["Department"].ToString();
        textBox10.Text = clss.reader["Emp_Name"].ToString();
        textBox9.Text = clss.reader["OfficeNumber"].ToString();
        listBox1.Items.Add(clss.reader["AllocationDate"].ToString());
    }

    clss.reader.Close();
}

Please clarify what clss exactly is... Otherwise my only solution is doing this:请澄清 clss 究竟是什么......否则我唯一的解决方案是这样做:

Make sure you are not missing any parameters for example:确保您没有遗漏任何参数,例如:

public class Employee {
    public Employee(string Name) {
       // Some Code Here
    }
}

To me clss looks like that but not named Employee and most likely has different arguments.对我来说 clss 看起来像那样但没有命名为 Employee 并且很可能有不同的论点。 So for the example below it shows that i want to create a new object from the Employee class, and it shows which one triggers the error and which one doesn't.因此,对于下面的示例,它表明我想从 Employee 类创建一个新对象,并显示哪个触发了错误,哪个没有。

Employee karen = new Employee();员工卡伦 = 新员工(); // Triggers the Error // 触发错误

Employee karen = new Employee("Karen");员工卡伦 = new Employee("卡伦"); // Doesn't Trigger Error // 不触发错误

I am sorry if this does not help you, Or it is not actually going to work as i suppose.如果这对您没有帮助,我很抱歉,或者它实际上不会像我想象的那样工作。 This is the first time I've tried to answer a question.这是我第一次尝试回答问题。 And it's been a while since I've stopped coding in C#.自从我停止使用 C# 编码以来已经有一段时间了。

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

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