I'm trying to do an app without adding some details about a car delivery.
I wrote the code in C# and SQL, but when I add the data to textbox, radiobutton, labels, etc. I get this error:
System.Data.SqlClient.SqlException: 'The parameterized query '(@a int,@b nvarchar(7),@c int,@d nvarchar(12),@e nvarchar(10),@f' expects the parameter '@f', which was not supplied.'
But I tried by debug to see if they take values and all have values less @f
The length of the columns in the database is 50 or 100
if (materialRadioButton5.Checked)
{
choose = "Excelent";
}
else if (materialRadioButton8.Checked)
{
choose = "Foarte bună";
}
else if (materialRadioButton7.Checked)
{
choose = "Bună";
}
else if (materialRadioButton6.Checked)
{
choose = "Uzată";
}
if (materialRadioButton4.Checked)
{
chooser = "Mulţumit";
}
else if (materialRadioButton1.Checked)
{
chooser = "Nemulţumit";
}
SqlConnection con = new SqlConnection(stringcon);
SqlCommand cmd = new SqlCommand();
con.Open();
cmd.Connection = con;
cmd.Parameters.Clear();
cmd.CommandText = "insert into returncar(id_client,fullname_client,id_team,fullname_team,rendition,condition,team_mention,customers_plesed,exp_felt,client_mention) values(@a,@b,@c,@d,@e,@f,@g,@h,@i,@j)";
cmd.Parameters.AddWithValue("@a", Convert.ToInt32(label65.Text));
cmd.Parameters.AddWithValue("@b", label67.Text);
cmd.Parameters.AddWithValue("@c", Convert.ToInt32(label66.Text));
cmd.Parameters.AddWithValue("@d", label68.Text);
cmd.Parameters.AddWithValue("@e", metroDateTime1.Text);
cmd.Parameters.AddWithValue("@f", choose);
cmd.Parameters.AddWithValue("@g", firstname_textbox.Text);
cmd.Parameters.AddWithValue("@h", chooser);
cmd.Parameters.AddWithValue("@i", role_dropbox.selectedValue);
cmd.Parameters.AddWithValue("@j", materialSingleLineTextField1.Text);
cmd.ExecuteNonQuery();
SqlCommand cmd2 = new SqlCommand();
cmd2.Connection = con;
cmd2.Parameters.Clear();
cmd2.CommandText = "update rentcar set inchiriat=0 where id=@id";
cmd2.Parameters.AddWithValue("@id", Form2.idddloan);
cmd2.ExecuteNonQuery();
con.Close();
panel2.Visible = false;
bunifuFlatButton7.Visible = false;
How radiobutton4 and radiobutton1 works and the others do not?...
public string choose, chooser;
chooseas@f, notchooser. If materialRadioButton1 and 4 aren't checked,chooseis probably null - 15ee8f99-57ff-4f92-890c-b56153