Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

He Everybody.

 

This is the first time I am going to use VS.Net (2003) to create a simple app with data, using MSAccess as the back-end and used drag-and-drop with the data objects.

I created the project. Dropped-in a TABLE I found in the Server Explorer, follow the wizard.

Fill a datatable with the OleDBDataAdapter object. Add a DataGrid, set the DataSource property to the Datatable(using code).

 

Now I add the "Save Button", how would I go about saving the changes typed into the DataGrid?

 

All inputs will be greatly appreciated.

  • *Experts*
Posted

You'll be wanting to look at the DataAdapter class. The DataAdapter is the piece that goes between the DataSet and the DataBase. The DataAdapter is meant to be easy to use, supporting the 4 main DB commands: SelectCommand, InsertCommand, UpdateCommand and DeleteCommand. There's even support for it to build all of those commands for you (such as basic SELECT, INSERT, etc. SQL statements) assuming you don't have any reserved words for table or column names.

 

You'll end up calling an "Update" method on the DataAdapter, which will send the updates in your DataSet to the database (Access in your case). Each row in the DataSet has a "rowstate", such as "Unmodified", "Modified", "Deleted", etc. It's that rowstate that determines which command the DataAdapter will run. So if you've modified 1 row then the DataAdapter would call the UpdateCommand 1 time.

 

After you call the Update method, you'll generally call AcceptChanges on the DataSet. It's probably worthwhile to find an article (or a set of them) or a book on the basic flow, to outline the "Why's" of the DataAdapter and DataSet.AcceptChanges and other things I'm leaving out.

 

-ner

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...