I am trying to insert the data into the database but the values inserted in the database are displayed null. There are also warnings like "Fields (x) is never assigned to and will always have its default value null" ( x = response1, response2, response3, response4, response5)
private void YesOrNoChecked(RadioButton radioButtonYes, RadioButton radioButtonNo,string response,int questionNo)
{
if (radioButtonYes.Checked)
{
response = "Yes";
}
else if (radioButtonNo.Checked)
{
response = "No";
}
else
{
MessageBox.Show("Question " + questionNo + " is not answered", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning);
isChecked = false;
}
}
private void SatisfactionChecked(RadioButton rdoVerySatisfied, RadioButton rdoSatisfied, RadioButton rdoNeutral,
RadioButton rdoDissatisfied, RadioButton rdoVeryDissatisfied,string response,int questionNo)
{
if (rdoVerySatisfied.Checked)
{
response = "Very Satisfied";
}
else if (rdoSatisfied.Checked)
{
response = "Satisfied";
}
else if (rdoNeutral.Checked)
{
response = "Neutral";
}
else if (rdoDissatisfied.Checked)
{
response = "Dissatisfied";
}
else if (rdoVeryDissatisfied.Checked)
{
response = "Very Dissatisfied";
}
else
{
MessageBox.Show("Question " + questionNo + " is not answered", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning);
isChecked = false;
}
}
I called the functions...
YesOrNoChecked(rdoYes1, rdoNo1, response1, 1);
YesOrNoChecked(rdoYes2, rdoNo2, response2, 2);
SatisfactionChecked(rdoVerySatisfied3, rdoSatisfied3, rdoNeutral3, rdoDissatisfied3, rdoVeryDissatisfied3, response3, 3);
SatisfactionChecked(rdoVerySatisfied4, rdoSatisfied4, rdoNeutral4, rdoDissatisfied4, rdoVeryDissatisfied4, response4, 4);
SatisfactionChecked(rdoVerySatisfied5, rdoSatisfied5, rdoNeutral5, rdoDissatisfied5, rdoVeryDissatisfied5, response5, 5);
I insert the data into the database
consumerResponsesTableAdapter.InsertConsumerResponses(lblSurveyDate.Text,
consumerID, ConsumerMenu.surveyID, response1, response2, response3, response4, response5, response6);
Is there any way to fix this?
question from:
https://stackoverflow.com/questions/65939211/warning-fields-is-never-assigned-to-and-will-always-have-its-default-value