Search code examples
sql-servervb.netvb6daovb6-migration

VB6/Microsoft Access/DAO to VB.NET/SQL Server... Got Advice?


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?


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.