943,809 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 919
  • C# RSS
Aug 4th, 2008
0

Overloading method

Expand Post »
Hello all,
I have overloading method problem with my miniproject. The code is below :
C# Syntax (Toggle Plain Text)
  1. patients.UpdatePatientsDetail(patientsidTextBox.Text, patientsnameLabel1.Text);

Error is : no overload for UpdatePatientsDetail takes '2' arguments
Code for this method is :
C# Syntax (Toggle Plain Text)
  1. public void UpdatePatientsDetail(string strPatientsID, string strPatientsName, string strPatientsAddress, string strPatientsTelephonenumber, string strPatientsDateofBirth, string strPatientsNric, string strPatientsEmailAdress, string strPatientsApponitmentTime)
  2. {
  3. string SQL;
  4. SQL = "UPDATE Patients SET PatientsName = '" + strPatientsName +
  5. "', PatientsAddress = '" + strPatientsAddress +
  6. "', PatientsTelephonenumber = '" + strPatientsTelephonenumber +
  7. "', PatientsDateofBirth = '" + strPatientsDateofBirth +
  8. "', PatientsNric = '" + strPatientsNric +
  9. "', PatientsEmailAdress = '" + strPatientsEmailAdress +
  10. "', PatientsAppointmentTime = '" + strPatientsApponitmentTime +
  11. "' where PatientsID = " + strPatientsID + "";
  12. ExecuteDataCommand(SQL);
  13. }

I can't fix the error. Any help will be appreciated. Thank you.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
Hannahlv is offline Offline
31 posts
since Jul 2008
Aug 4th, 2008
0

Re: Overloading method

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
Reputation Points: 12
Solved Threads: 1
Newbie Poster
tostrinj is offline Offline
20 posts
since Jul 2007
Aug 5th, 2008
0

Re: Overloading method

Thank you for your reply.
I still got error can't overload the method.
C# Syntax (Toggle Plain Text)
  1. consu.UpdateConsultationDetail(consultationidTextBox.Text, consultationdateTextBox.Text, patientspastillnessComboBox.Items.Add, patientspastdiagnosisComboBox.Items.Add, patientscurrentillnessTextBox.Text, patientscurrentdiagnosisComboBox.Items.Add);

The method is below :
C# Syntax (Toggle Plain Text)
  1.  
  2. public void UpdateConsultationDetail(string strConsultationID, string strDiagnosis, string strConsultationDate, string strPatientsPastIllness, string strPatientsCurrentIllness, string strPatientsPastDiagnosis, string strPatientsCurrentDiagnosis)
  3. {
  4. string SQL;
  5. SQL = "UPDATE Consultation SET ConsultationDate = '" + strConsultationDate +
  6. "', PatientsPastIllness = '" + strPatientsPastIllness +
  7. "', PatientsPastDiagnosis = '" + strPatientsPastDiagnosis +
  8. "', PatientsCurrentDiagnosis = '" + strPatientsCurrentDiagnosis +
  9. "', PatientsCurrentIllness = '" + strPatientsCurrentIllness +
  10. "' where ConsultationID = " + strConsultationID + "";
  11. ExecuteDataCommand(SQL);
  12. }

How to fix it? I passed enough parameters but still got error. Thanks.
Last edited by Hannahlv; Aug 5th, 2008 at 12:44 am.
Reputation Points: 10
Solved Threads: 0
Light Poster
Hannahlv is offline Offline
31 posts
since Jul 2008
Aug 5th, 2008
0

Re: Overloading method

I think you passed the wrong parameters.

Quote ...
patientspastillnessComboBox.Items.Add
patientspastdiagnosisComboBox.Items.Add,
patientscurrentdiagnosisComboBox.Items.Add
is it the String above three parameters?

As I knew, those means that the event.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
airyym is offline Offline
2 posts
since Aug 2008
Aug 5th, 2008
0

Re: Overloading method

Cool!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
jmneter is offline Offline
1 posts
since Jul 2008
Aug 5th, 2008
0

Re: Overloading method

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?
Reputation Points: 10
Solved Threads: 0
Light Poster
Hannahlv is offline Offline
31 posts
since Jul 2008
Aug 5th, 2008
0

Re: Overloading method

That's easy way here.

Your method :

Quote ...
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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
airyym is offline Offline
2 posts
since Aug 2008
Aug 5th, 2008
0

Re: Overloading method

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)
Reputation Points: 10
Solved Threads: 0
Light Poster
Hannahlv is offline Offline
31 posts
since Jul 2008
Aug 5th, 2008
0

Re: Overloading method

Click to Expand / Collapse  Quote originally posted by Hannahlv ...
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()
Reputation Points: 10
Solved Threads: 2
Light Poster
ramiljoaquin is offline Offline
37 posts
since Jun 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: problem after file modification with formatting
Next Thread in C# Forum Timeline: Gif image Extraction





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC