C# data commit question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • narpet
    New Member
    • Oct 2006
    • 69

    #1

    C# data commit question

    Hello all...

    I know this is probably very easy and I'm just missing it... but I've been trying to learn C# on my own at work and this problem has me stumped.

    I am able to connect to my SQL database and view data with no problem.

    As an example I created a datagrid view on a form that shows some data from a table.

    What I want to do is allow the user to change data and have that data change committed to the database. As it is the user can change data, but it's never actually committed to the database.

    I've read all over the place trying to figure this out... and I'm sure it's easy...

    Can anyone help me with how to save changes to the SQL database that are made in a datagrid view on a form?

    Thanks!
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by narpet
    Hello all...

    I know this is probably very easy and I'm just missing it... but I've been trying to learn C# on my own at work and this problem has me stumped.

    I am able to connect to my SQL database and view data with no problem.

    As an example I created a datagrid view on a form that shows some data from a table.

    What I want to do is allow the user to change data and have that data change committed to the database. As it is the user can change data, but it's never actually committed to the database.

    I've read all over the place trying to figure this out... and I'm sure it's easy...

    Can anyone help me with how to save changes to the SQL database that are made in a datagrid view on a form?

    Thanks!
    Perhaps if you post the code that's not working ...

    Comment

    • Plater
      Recognized Expert Expert
      • Apr 2007
      • 7872

      #3
      You would need to use an Update command. However, we would probably need to see the situation you are in order to suggest anything further. (Manual use vs automated from a dataset)

      Comment

      • narpet
        New Member
        • Oct 2006
        • 69

        #4
        There's really no code to show at this point...

        The entire form was created using MS Visual Dev Studio... so it generated all the code for me.

        I'm using a defined dataset, and for the datagrid view I'm using a defined table adapter. So it is all auto created.

        I hope this info helps...

        we can just call the datagrid... datagridview1
        call the dataset... dataset1
        call the table adapter... adapter1
        call the binding source... bind1

        Like I said... this is all new to me... but I've been able to fill data views, filter those views... just about anything that doesn't actually change the actual database. But that's what I need to do the most (of course).

        Any ideas??

        Comment

        • Plater
          Recognized Expert Expert
          • Apr 2007
          • 7872

          #5
          I believe you can use the designer to create UpdateCommand (although if it goes on the dataset or the datagridview I dunno, I've only seen people talk about it), just to do a quick google/msdn search for it?

          Comment

          Working...