I use this code to save a new word to my database :
When I close my application and reopen it, my database has the new word in it, but after reopening and closing the application a few times, suddenly the database is to it's old state again?!? What's happening?Code:private void btnOpslaan_Click(object sender, EventArgs e) { System.Data.SqlClient.SqlCommandBuilder cb; cb = new System.Data.SqlClient.SqlCommandBuilder(da); DataRow dRow = ds1.Tables["Woorden"].NewRow(); dRow[1] = txtWoord.Text; ds1.Tables["Woorden"].Rows.Add(dRow); iMaxRows++; iIndex = iMaxRows - 1; try { da.Update(ds1, "Woorden"); } catch (DBConcurrencyException ex) { string customErrorMessage; customErrorMessage = "Concurrency violation\n" + ex.ToString(); MessageBox.Show(customErrorMessage); // Add business logic code to resolve the concurrency violation... return; } MessageBox.Show("Nieuw woord toegevoegd aan de database."); btnOpslaan.Enabled = false; btnVerwijderen.Enabled = true; btnNieuw.Enabled = true; btnAnnuleren.Enabled = false; txtWoord.Enabled = false; ReloadDatabase(); }


Reply With Quote

Bookmarks