Hello all,
I have overloading method problem with my miniproject. The code is below :

patients.UpdatePatientsDetail(patientsidTextBox.Text, patientsnameLabel1.Text);

Error is : no overload for UpdatePatientsDetail takes '2' arguments
Code for this method is :

public void UpdatePatientsDetail(string strPatientsID, string strPatientsName, string strPatientsAddress, string strPatientsTelephonenumber, string strPatientsDateofBirth, string strPatientsNric, string strPatientsEmailAdress, string strPatientsApponitmentTime)
        {
            string SQL;
            SQL = "UPDATE Patients SET PatientsName = '" + strPatientsName +
                "', PatientsAddress = '" + strPatientsAddress +
                "', PatientsTelephonenumber = '" + strPatientsTelephonenumber +
                "', PatientsDateofBirth = '" + strPatientsDateofBirth + 
                "', PatientsNric = '" + strPatientsNric +
                "', PatientsEmailAdress = '" + strPatientsEmailAdress +
                "', PatientsAppointmentTime = '" + strPatientsApponitmentTime +
                "' where PatientsID = " + strPatientsID + "";
            ExecuteDataCommand(SQL);
        }

I can't fix the error. Any help will be appreciated. Thank you.

Recommended Answers

All 8 Replies

Your method takes 8 parameters, and you are trying to call it with just two params. Either give it all 8 or override the UpdatePatientDetails() to take 2 parameters

Thank you for your reply.
I still got error can't overload the method.

consu.UpdateConsultationDetail(consultationidTextBox.Text, consultationdateTextBox.Text, patientspastillnessComboBox.Items.Add, patientspastdiagnosisComboBox.Items.Add, patientscurrentillnessTextBox.Text, patientscurrentdiagnosisComboBox.Items.Add);

The method is below :

public void UpdateConsultationDetail(string strConsultationID, string strDiagnosis, string strConsultationDate, string strPatientsPastIllness, string strPatientsCurrentIllness, string strPatientsPastDiagnosis, string strPatientsCurrentDiagnosis)
        {
            string SQL;
            SQL = "UPDATE Consultation SET ConsultationDate = '" + strConsultationDate +
                "', PatientsPastIllness = '" + strPatientsPastIllness +
                "', PatientsPastDiagnosis = '" + strPatientsPastDiagnosis +
                "', PatientsCurrentDiagnosis = '" + strPatientsCurrentDiagnosis +
                "', PatientsCurrentIllness = '" + strPatientsCurrentIllness +
                "' where ConsultationID = " + strConsultationID + "";
            ExecuteDataCommand(SQL);
        }

How to fix it? I passed enough parameters but still got error. Thanks.

I think you passed the wrong parameters.

patientspastillnessComboBox.Items.Add
patientspastdiagnosisComboBox.Items.Add,
patientscurrentdiagnosisComboBox.Items.Add

is it the String above three parameters?

As I knew, those means that the event.

Cool!

The parameters declare are strings, but those are all combobox and I want to pass all the content of combobox into the method. So now what should I do?

That's easy way here.

Your method :

consu.UpdateConsultationDetail(consultationidTextBox.Text, consultationdateTextBox.Text, patientspastillnessComboBox.Items.Add, patientspastdiagnosisComboBox.Items.Add, patientscurrentillnessTextBox.Text, patientscurrentdiagnosisComboBox.Items.Add);

changed into:

consu.UpdateConsultationDetail(consultationidTextBox.Text, consultationdateTextBox.Text, patientspastillnessComboBox, patientspastdiagnosisComboBox, patientscurrentillnessTextBox.Text, patientscurrentdiagnosisComboBox);

after doing this,

you can choose items in CheckBox in the method by

(String)patientspastillnessComboBox.Items[INDEX_NUM]; // INDEX_NUM: 0 ~ n(existed item number)

I hope this reply help you.

Thanks for the reply now the problem is that i dont know where to add this code String)patientspastillnessComboBox.Items[INDEX_NUM]; // INDEX_NUM: 0 ~ n(existed item number)

Thanks for the reply now the problem is that i dont know where to add this code String)patientspastillnessComboBox.Items[INDEX_NUM]; // INDEX_NUM: 0 ~ n(existed item number)

Change the code of all combobox.

from:
patientspastdiagnosisComboBox.Items.Add

to:
patientspastdiagnosisComboBox.SelectedItem.ToString()

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.