Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Problem saving changes to a database VS C# 2005

Problem saving changes to a database VS C# 2005

Scheduled Pinned Locked Moved C#
csharpdatabasevisual-studiowpfwcf
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    danielhasdibs
    wrote on last edited by
    #1

    I'm no stranger to programming, but I am brand new to programming with databases. I use MS Visual C# 2005. I have tried making forms with datasets and table adapters and it looks just fine... that is, until I try to make a change. I have a simple form with a single datagridview. I edit the records, click the Save button on the binding navigator, the tableadapter.Update() method returns the correct number of updated rows, but when I close the program and re-open it, the changes aren't there. Am I leaving out something? Is there extra code needed? etc.? Thanks.

    R P D N 5 Replies Last reply
    0
    • D danielhasdibs

      I'm no stranger to programming, but I am brand new to programming with databases. I use MS Visual C# 2005. I have tried making forms with datasets and table adapters and it looks just fine... that is, until I try to make a change. I have a simple form with a single datagridview. I edit the records, click the Save button on the binding navigator, the tableadapter.Update() method returns the correct number of updated rows, but when I close the program and re-open it, the changes aren't there. Am I leaving out something? Is there extra code needed? etc.? Thanks.

      R Offline
      R Offline
      Rajasekharan Vengalil
      wrote on last edited by
      #2

      danielhasdibs wrote:

      Am I leaving out something?

      Yes.

      danielhasdibs wrote:

      Is there extra code needed?

      Yes.

      danielhasdibs wrote:

      etc.?

      Yes. Seriously though, there are any number of things that could be wrong. Is your query for fetching the data to initialize your grid view somehow filtering out the new rows? Are your updates part of a transaction that is never committed? If you are running SQL Server and have all the client tools, see if you can run "SQL Profiler" to see what queries are being run when you save your data.

      -- gleat http://blogorama.nerdworks.in[^] --

      Number Two's eyes narrowed and became what are known in the Shouting and Killing People trade as cold slits, the idea presumably being to give your opponent the impression that you have lost your glasses or are having difficulty keeping awake. Why this is frightening is an, as yet, unresolved problem. -- HHGTG

      1 Reply Last reply
      0
      • D danielhasdibs

        I'm no stranger to programming, but I am brand new to programming with databases. I use MS Visual C# 2005. I have tried making forms with datasets and table adapters and it looks just fine... that is, until I try to make a change. I have a simple form with a single datagridview. I edit the records, click the Save button on the binding navigator, the tableadapter.Update() method returns the correct number of updated rows, but when I close the program and re-open it, the changes aren't there. Am I leaving out something? Is there extra code needed? etc.? Thanks.

        P Offline
        P Offline
        Paul Conrad
        wrote on last edited by
        #3

        Well, can you provide a sample of the code so folks can see what is going on?

        "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham

        D 1 Reply Last reply
        0
        • D danielhasdibs

          I'm no stranger to programming, but I am brand new to programming with databases. I use MS Visual C# 2005. I have tried making forms with datasets and table adapters and it looks just fine... that is, until I try to make a change. I have a simple form with a single datagridview. I edit the records, click the Save button on the binding navigator, the tableadapter.Update() method returns the correct number of updated rows, but when I close the program and re-open it, the changes aren't there. Am I leaving out something? Is there extra code needed? etc.? Thanks.

          D Offline
          D Offline
          danielhasdibs
          wrote on last edited by
          #4

          Here is what I do: I open a new project, I create a database, I enter one table into the database, I add three or four records to the table, I add the database as a data source, I drag the table from the data source to the form to create a datagridview, I run the program, I edit/add records on the form and click the Save button from the binding navigator, I close the program, I re-open the program, and the changes are not there. What am I missing?

          1 Reply Last reply
          0
          • P Paul Conrad

            Well, can you provide a sample of the code so folks can see what is going on?

            "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham

            D Offline
            D Offline
            danielhasdibs
            wrote on last edited by
            #5

            Here is what I do: I open a new project, I create a database, I enter one table into the database, I add three or four records to the table, I add the database as a data source, I drag the table from the data source to the form to create a datagridview, I run the program, I edit/add records on the form and click the Save button from the binding navigator, I close the program, I re-open the program, and the changes are not there. What am I missing? Here's the code for the save button click event:

            private void customerBindingNavigatorSaveItem_Click(object sender, EventArgs e)
                    {
                        this.Validate();
                        this.customerBindingSource.EndEdit();
                        this.customerTableAdapter.Update(this.myCompanyDataSet.Customer);
            
                    }
            
            1 Reply Last reply
            0
            • D danielhasdibs

              I'm no stranger to programming, but I am brand new to programming with databases. I use MS Visual C# 2005. I have tried making forms with datasets and table adapters and it looks just fine... that is, until I try to make a change. I have a simple form with a single datagridview. I edit the records, click the Save button on the binding navigator, the tableadapter.Update() method returns the correct number of updated rows, but when I close the program and re-open it, the changes aren't there. Am I leaving out something? Is there extra code needed? etc.? Thanks.

              D Offline
              D Offline
              danielhasdibs
              wrote on last edited by
              #6

              I found the answer: SOLUTION: 1. Right Click Properties on tablename.mdf in Solution Explorer 2. Set the "Copy to Output Directory" property to "Copy if newer" 3. Run the program, and it should work in the IDE.

              1 Reply Last reply
              0
              • D danielhasdibs

                I'm no stranger to programming, but I am brand new to programming with databases. I use MS Visual C# 2005. I have tried making forms with datasets and table adapters and it looks just fine... that is, until I try to make a change. I have a simple form with a single datagridview. I edit the records, click the Save button on the binding navigator, the tableadapter.Update() method returns the correct number of updated rows, but when I close the program and re-open it, the changes aren't there. Am I leaving out something? Is there extra code needed? etc.? Thanks.

                N Offline
                N Offline
                nelsonpaixao
                wrote on last edited by
                #7

                Hi Daniel, In C# i add/edit/delete database data by triggering store_procedures with help of a partcular event(most times a buttom_click). I really don´t edit the way you said because it accepts everthing, so i don´t do that stuff. I always create conditions!!! so that method doesn´t apply to me. So, i dont know if you have already your anwser, but remember that you are editing a database not the datagrdview!!! :|

                nelsonpaixao@yahoo.com.br trying to help & get help

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups