int dose = Convert.ToInt16(DoseTextBox.Text.ToString());
try
{
SqlCommand AddMed = new SqlCommand("INSERT INTO Medications VALUES(@Medication,@Dose,@manufacture)", mcs);
AddMed.Parameters.Add("@Medication", SqlDbType.NVarChar).Value = MedName.Text.ToString();
AddMed.Parameters.Add("@Dose", SqlDbType.Int).Value = dose;
AddMed.Parameters.Add("@manufacture", SqlDbType.NVarChar).Value = ManuDB.Text.ToString();
mcs.Open();
AddMed.ExecuteNonQuery();
mcs.Close();
MessageBox.Show("Med Added", "Done!");
}
catch (Exception)
{
MessageBox.Show("Oops!", "Something went wrong");
}
Am I doing anything wrong? The result of this function is "Med Added", but the Medication table doesn't seem to have any new rows no matter how many times I execute the query nor refresh the results using Ctrl+R
Am I missing something? I tried removing the ToString
method from the returned Value, but that is not the problem. I believe. The ManuDB is Manufacturer Drop Box.