|
-
November 6th, 2011, 07:38 AM
#1
saved to database or not?
I use this code to save a new word to my database :
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();
}
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?
-
November 6th, 2011, 05:23 PM
#2
Re: saved to database or not?
What is 'da' defined as? Are you debugging using thbe Visual Studio IDE? If so, everytime you recompile to start debugging a copy of the db overwrites the old one.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|