Question

I can make a DAO recordset in VB6/Access do anything - add data, clean data, move data, get data dressed in the morning and take it to school. But I don't even know where to start in .NET.

I'm not having any problems retrieving data from the database, but what do real people do when they need to edit data and put it back?

What's the easiest and most direct way to edit, update and append data into related tables in .NET and SQL Server?

Was it helpful?

Solution

The DataSet class is the place to start. As the linked article says, the steps for creating a DataSet, modifying it, then updating the database are typically:

  1. Build and fill each DataTable in a DataSet with data from a data source using a DataAdapter.
  2. Change the data in individual DataTable objects by adding, updating, or deleting DataRow objects.
  3. Invoke the GetChanges method to create a second DataSet that features only the changes to the data.
  4. Call the Update method of the DataAdapter, passing the second DataSet as an argument.
  5. Invoke the Merge method to merge the changes from the second DataSet into the first.
  6. Invoke the AcceptChanges on the DataSet. Alternatively, invoke RejectChanges to cancel the changes.

OTHER TIPS

A natural progression IMO from DAO is ADO.net. I think you would find it pretty easy to pick up having the understanding/foundation of DAO. It uses DataAdapters and DataSets similar to recordsets. Modifying Data in ADO.NET.

I would suggest looking into Linq when you get a chance.

try to use oledbConnection , oledbCommand and oledbDataReader

from System.data.oledb

if you are using sqlserver DB then from System.data.SqlClient

use SqlConnection , sqlCommand and sqlDataReader

Is there a reason why ms-access was added as a tag here? It seems to me that the question has nothing but the most trivial relevance to Access, since once you're working with .NET, Access is completely out of the picture.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top