couldnt I just enter dynamic data direct through the datagrid and then just update the table(In other words actually click on the datagrid and then type data in the list and then click on update). The added data will be movie titles, director etc so that I could just add to the list when I want to update.
Short answer is no. How will your application know what SQL to send to your database to insert, update, or delete records?
I wish I had a better answer for you, but this is how it works. There are other ways to do what you want within ADO.NET, but they require more code and more manual management of the database. I believe that what I'm describing here is one of the simpler methods, and I think the most decoupled from the database itself.
Longer answer:
DataGrid is there to provide a user interface. It can display and manage data based on a variety of underlying data-holding classes. We're looking at a
DataSet or
DataTable as the backing object for your
DataGrid . Both of these are in-memory representations,
i.e., they are a copy of your data, and they don't represent a direct connection to the database.
SqlDataAdapter is probably the easiest way manage the link between these data objects and your database. At a minimum, you need to write the
SELECT statement, and if you aren't able to use
SqlCommandBuilder you'll also need to write appropriate
INSERT ,
UPDATE , and
DELETE statements for full database operation. Once that's done, though, the adapter's
Update method takes care of all of the details.
If the .NET Framework 3.5 is available to you, there is also
LINQ. It provides a language-integrated query facility that is much more intuitive than ADO.NET mechanisms and takes considerably fewer lines of code to do the same things. Using LINQ, however, is a whole different discussion--I only mention it in case you aren't familiar with it.