|
-
Dec 29th, 2016, 10:51 AM
#6
Re: Input values into a DataGridView in a form and have them update to my Database.
You should. Binding a datatable to the DGV takes a single line. Updating a datatable back to the database will generally take four lines. Compare that to all that you were trying to do with that INSERT, and consider that the INSERT would only work the first time you entered the data. If you wanted to edit the data and save it again, you'd also need an UPDATE, which would be somewhat different from the INSERT. Meanwhile, with a datatable, the code that handled the inserting would also handle updating and deleting, as well.
The basic rule I would suggest would be this: If you are using a datagridview there should be a datatable behind it.
It's hard to think of an exception to this. It could be argued that you wouldn't need a datatable if you weren't storing/retrieving from a database, but even then you'd almost certainly be better off with a datatable.
My usual boring signature: Nothing
 
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|