SQL DataGridView
-
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?
-
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?
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
-
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
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.
-
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?
The updating is usually handled by a DataAdapter.Update -- but as has been said, you won't have a very impressive app.