Question Best way to create a data grid view

klharding

Member
Joined
Sep 16, 2008
Messages
8
Location
New Hampshire
Programming Experience
3-5
I am using VB.NET, Visual Studio 2008.

So I have been trying to figure this out for weeks. I can always fill the data grid view, but never insert or update rows. I think I just need to start fresh with a new data grid view.

Basically, I have 3 stored procedures...1 for select, 1 for update and 1 for insert. I would like to use these three stored procedures from the data grid view. I would like the data grid view to be bound.

So my question is...what is the best way to set up a data grid view? By using the wizards? Does anyone have a step-by-step resource I can try and follow?

Thanks in advance!

Kristen
 
If the grid id bound then it's data source is all the grid knows about. You use a DataAdapter to Fill a DataTable and then bind that to the grid. You can add, edit and delete rows in the grid and all those changes are automatically pushed to the bound DataTable, which is the whole point of data-binding in the first place. Once you're done making changes you use the same DataAdapter to Update the database and save the changes from the DataTable.

The easiest way to do all this is with a typed DataSet. That saves you having to write any of the SQL code and it also makes accessing your data in your own VB code easier. You can open the Data Sources window and create a new Data Source. The wizard will generate a typed DataSet that includes TableAdapters to retrieve and save data. You can then drag a table from the Data Sources window onto your form and all the components will be created for you, all the data-bindings configured and even some simple retrieve and save code will be generated.
 
Back
Top