I am trying insert some data into a database table using sql commands. I keep getting this error:
Must declare the scalar variable "@MC"
Code:
void CreateModule() {
Query = "INSERT INTO TblModules (Module_Code, Module_Name, Date,Start_Time, Duration) values ( @MC, @MN, @DATE, @ST, @DURATION)";
theReader = dc.ExecuteStatement(Query);
command.Parameters.AddWithValue("@MC", ModuleCodeTxt.Text);
command.Parameters.AddWithValue("@MN", ModulenameTxt.Text);
command.Parameters.AddWithValue("@DATE", MyDateTimePicker.Value);
command.Parameters.AddWithValue("@ST", comboBoxTime.SelectedItem);
command.Parameters.AddWithValue("@DURATION", comboBoxDuration.SelectedItem);
MessageBox.Show(" Module Created");
conn.CloseConnection();
}