0

Very simple one here, as i am incredibly new to coding C#. As you can see from the code iv'e supplied i'm trying to solve an error i'm receiving shown in the screenshot. Its occuring when i try to update current information held within my access database. As i said, probably a really simply one, but i cant see the error

enter image description here

private void btnSchedule_Click(object sender, EventArgs e)
    {
        try
        {

            connection.Open();
            OleDbCommand command = new OleDbCommand();
            command.Connection = connection;
            string query = "Update patients SET First = '" + txtFirst.Text 
               + "', Last='" + txtLast.Text 
               + "', Address='" + txtAddress.Text 
               + "', Phone='" + txtPhone.Text 
               + "', LastVisit='" + txtLastVisit.Text 
               + "', NextVisit='" + txtNextVisit.Text 
               + "', Doctor='" + comboDoctor.Text 
               + "' WHERE patients.ID =" + lblID.Text + " ";
            command.CommandText = query;
            command.ExecuteNonQuery();
            MessageBox.Show("User Updated");
            connection.Close();
        }
        catch (Exception ex)
        {
            MessageBox.Show("User not updated " + ex);
        }
    }
Roman Marusyk
  • 23,328
  • 24
  • 73
  • 116

0 Answers0