private void locationsUpdateButton_Click(object sender, EventArgs e) { databaseController dbc = new databaseController(); string selectedLocation = locationslistBox.SelectedItem.ToString();//exception needs to be handled selectedLocation = selectedLocation.Trim(); string[] LocationID = selectedLocation.Split('|'); selectedLocation = LocationID[1].Trim(); string postalcode = LocationID[2].Trim(); int id_l = Convert.ToInt32(LocationID[0].Trim()); selectedLocation = locationsNameTextBox.Text; postalcode = postalLocationsTextBox.Text; MessageBox.Show(Convert.ToString(id_l)); MessageBox.Show(selectedLocation); MessageBox.Show(postalcode); Locations loc = new Locations(id_l, selectedLocation, postalcode); dbc.UpdateLocations(loc); locationslistBox.Items.Clear(); OutputLocations(); }