I've checked the answers on this topic however I still have no idea why this is not working! PLEASE HELP!
private void btnAdd_Click(object sender, EventArgs e)
{
SqlCeCommand insTitle = new SqlCeCommand("Insert into Titles(Title) values('" + txtAddTitle.Text +"')");
insTitle.Connection = dbConnection;
try
{
if (dbConnection.State == ConnectionState.Closed) { dbConnection.Open(); }
insTitle.ExecuteNonQuery();
this.hRDataSet.AcceptChanges();
this.titlesTableAdapter.Update(this.hRDataSet);
this.tableAdapterManager.UpdateAll(this.hRDataSet);
lstTitles.BeginUpdate();
lstTitles.DataSource = titlesBindingSource;
lstTitles.DisplayMember = "Title";
lstTitles.ValueMember = "Title_ID";
lstTitles.EndUpdate();
}
catch (Exception insErr)
{
MessageBox.Show(insErr.Message);
}
}
The listbox "lstTitles" won't refresh and doesn't show the added items despite the fact that they are in the database!