我是个菜鸟~在改其他人的程序~出现问题ContactsAdd没有采用“10”个参数的重载~
我知道问题原因是要求参数个数与你传入个数不同
不过我想不要那最后一个参数 应该怎么改?
private void button10_Click(object sender, EventArgs e)//添加
{
if (textBox1.Text != "" &&comboBox1.Text != "" && comboBox2.Text != "")
{
if (op.ContactsAdd(this.textBox1.Text, this.comboBox1.Text, this.dateTimePicker1.Text, this.comboBox2.Text, this.textBox7.Text, this.textBox8.Text, this.textBox3.Text, this.textBox5.Text, this.textBox4.Text, this.textBox9.Text ) == true)
{
MessageBox.Show("添加成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); }
else
{
MessageBox.Show("添加失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
我知道问题原因是要求参数个数与你传入个数不同
不过我想不要那最后一个参数 应该怎么改?
private void button10_Click(object sender, EventArgs e)//添加
{
if (textBox1.Text != "" &&comboBox1.Text != "" && comboBox2.Text != "")
{
if (op.ContactsAdd(this.textBox1.Text, this.comboBox1.Text, this.dateTimePicker1.Text, this.comboBox2.Text, this.textBox7.Text, this.textBox8.Text, this.textBox3.Text, this.textBox5.Text, this.textBox4.Text, this.textBox9.Text ) == true)
{
MessageBox.Show("添加成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); }
else
{
MessageBox.Show("添加失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
例如:if(par10 !=null)那么你在前台就传null,关键还在于方法里面的判断,根据判断去传参数,确保不会出现问题。