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. SQL DataGridView

SQL DataGridView

Scheduled Pinned Locked Moved C#
csharpdatabasequestionhelptutorial
4 Posts 3 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.
  • F Offline
    F Offline
    Falterfire
    wrote on last edited by
    #1

    Okay, so I'm thinking my problem here probably involves completely misunderstanding the use of a DataGridView, but here goes: I'm currently working on learning how to use SQL with C#/.NET using VS2010. I created a DataGridView that's linked to my data table. Adding rows to the DataGridView while the program was running did not actually save the changes to the database, so I created a separate piece using SqlConnection & SqlCommand. This successfully added the rows to the database, but did not update the DataGridView. So I suppose there are two questions here: How do I save the changes to a DataGridView to the bound data table? and How do I have the DataGridView reload table data?

    D P 2 Replies Last reply
    0
    • F Falterfire

      Okay, so I'm thinking my problem here probably involves completely misunderstanding the use of a DataGridView, but here goes: I'm currently working on learning how to use SQL with C#/.NET using VS2010. I created a DataGridView that's linked to my data table. Adding rows to the DataGridView while the program was running did not actually save the changes to the database, so I created a separate piece using SqlConnection & SqlCommand. This successfully added the rows to the database, but did not update the DataGridView. So I suppose there are two questions here: How do I save the changes to a DataGridView to the bound data table? and How do I have the DataGridView reload table data?

      D Offline
      D Offline
      Dan Mos
      wrote on last edited by
      #2

      While this most definitely doesn't answer your question, here goes: Don't use DataGridViews to enter/introduce/edit data. Use dedicated windows/forms. You're life gets a whole lot easier. The reasons are plenty: more control(like data validation), easier to debug, the app looks nicer... I only use DataGridViews for displaying data(if that). :)

      All the best, Dan

      F 1 Reply Last reply
      0
      • D Dan Mos

        While this most definitely doesn't answer your question, here goes: Don't use DataGridViews to enter/introduce/edit data. Use dedicated windows/forms. You're life gets a whole lot easier. The reasons are plenty: more control(like data validation), easier to debug, the app looks nicer... I only use DataGridViews for displaying data(if that). :)

        All the best, Dan

        F Offline
        F Offline
        Falterfire
        wrote on last edited by
        #3

        Good to know. Given that I'm at this point just trying to figure out how to use SQL in C#, it's good to know which pieces to avoid. So yes, that answer was useful, even if it didn't actually answer my specific question.

        1 Reply Last reply
        0
        • F Falterfire

          Okay, so I'm thinking my problem here probably involves completely misunderstanding the use of a DataGridView, but here goes: I'm currently working on learning how to use SQL with C#/.NET using VS2010. I created a DataGridView that's linked to my data table. Adding rows to the DataGridView while the program was running did not actually save the changes to the database, so I created a separate piece using SqlConnection & SqlCommand. This successfully added the rows to the database, but did not update the DataGridView. So I suppose there are two questions here: How do I save the changes to a DataGridView to the bound data table? and How do I have the DataGridView reload table data?

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #4

          The updating is usually handled by a DataAdapter.Update -- but as has been said, you won't have a very impressive app.

          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