saved to database or not?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 2 of 2

Thread: saved to database or not?

  1. #1
    Join Date
    Apr 2005

    saved to database or not?

    I use this code to save a new word to my database :

    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;
                iIndex = iMaxRows - 1;
                    da.Update(ds1, "Woorden");
                catch (DBConcurrencyException ex)
                    string customErrorMessage;
                    customErrorMessage = "Concurrency violation\n" + ex.ToString();
                    // Add business logic code to resolve the concurrency violation...
                MessageBox.Show("Nieuw woord toegevoegd aan de database.");
                btnOpslaan.Enabled = false;
                btnVerwijderen.Enabled = true;
                btnNieuw.Enabled = true;
                btnAnnuleren.Enabled = false;
                txtWoord.Enabled = false;
    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?

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004

    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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

This is a survey!

HTML5 Development Center