Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 No overload for method 'FillByEmployeeID' takes '2

Author  Topic 

zhshqzyc
Posting Yak Master

240 Posts

Posted - 2007-10-19 : 21:23:33
Hello, I am designing a small databse example.
The database only contains one table 'Employee'.
Only five fields: EmployeeID(primary key), firstName,lastName,phoneNumber,Salary.
Salary is an integer.
Now I drag some buttons to the form. One button is to find employee by ID, find employee by last name and find all employees inside a certain salary range.
My Table Adapter--Change the Update and Delete command to only need 1
parameter(primary key).
But I get three compiling errors.

Error 1 No overload for method 'FillByEmployeeID' takes '2' arguments
Error 2 No overload for method 'FillBylastName' takes '2' arguments
Error 3 No overload for method 'FillBySalary' takes '2' arguments

Here is my codes

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace HUIDB
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void employeeBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
this.Validate();
this.employeeBindingSource.EndEdit();
this.employeeTableAdapter.Update(this.dataSet1.Employee);

}

private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'dataSet1.Employee' table. You can move, or remove it, as needed.
this.employeeTableAdapter.Fill(this.dataSet1.Employee);

}


private void ADD_Click(object sender, EventArgs e)
{
String EmployeeID = textBox1.Text;
String firstName = textBox2.Text;
String lastName = textBox3.Text;
String phoneNumber = textBox4.Text;
int Salary = Int32.Parse(textBox5.Text);
employeeTableAdapter.Fill(this.dataSet1.Employee);
}

private void DELETE_Click(object sender, EventArgs e)
{
String EmployeeID = textBox1.Text;
if (this.employeeTableAdapter.Delete(EmployeeID) == 0)
MessageBox.Show("Deletion failed");
else
this.employeeTableAdapter.Fill(this.dataSet1.Employee);
}

private void UPDATE_Click(object sender, EventArgs e)
{
String EmployeeID = textBox1.Text;
String firstName = textBox2.Text;
String lastName = textBox3.Text;
String phoneNumber = textBox4.Text;
int Salary = Int32.Parse(textBox5.Text);
if (this.employeeTableAdapter.Update(EmployeeID, firstName, lastName, phoneNumber,Salary, EmployeeID) == 0)
MessageBox.Show("Update failed");
else
this.employeeTableAdapter.Fill(this.dataSet1.Employee);
}

private void FIND_Click(object sender, EventArgs e)
{
String EmployeeID = textBox1.Text;
String lastName = textBox3.Text;
int Salary = Int32.Parse(textBox5.Text);
this.employeeTableAdapter.FillByEmployeeID(dataSet1.Employee, EmployeeID); // wrong here
this.employeeTableAdapter.FillBylastName(dataSet1.Employee, lastName); // wrong here
this.employeeTableAdapter.FillBySalary(dataSet1.Employee, Salary); // wrong here
}

private void REFRESH_Click(object sender, EventArgs e)
{
this.employeeTableAdapter.Fill(this.dataSet1.Employee);
}
}
}

Could you please give me some advice?
Thanks!

zhshqzyc
Posting Yak Master

240 Posts

Posted - 2007-10-20 : 11:52:21
The three SQL queries are


SELECT EmployeeID,firstName,lastName,phoneNumber,Salary
FROM Employee
WHERE (EmployeeID='005')


SELECT EmployeeID,firstName,lastName,phoneNumber,Salary
FROM Employee
WHERE (lastName='Tart')


SELECT EmployeeID,firstName,lastName,phoneNumber,Salary
FROM Employee
WHERE (Salary >= 25000) AND (Salary < 70000)

So how to modify code or change SQL queries?


Thanks!




Go to Top of Page
   

- Advertisement -