Ado.Recordset.AddNew, .Update, .MoveFirst, .Delete, etc...

  • Thread starter Thread starter tony010409020622
  • Start date Start date
T

tony010409020622

I just spent 4 months taking a dotnet class where i learned very
little. One of the things I did not learn is this: What are the
dotnet equivilents of commands such as:

Adodc1.Recordset.AddNew
Adodc1.Recordset.Update
Adodc1.Recordset.MoveFirst
Adodc1.Recordset.MoveNext
Adodc1.Recordset.Delete

I understand how to connect to the database, set up the data adapter,
create a dataset, but USING any of this data in a practical way seemed
way beyond the knowledge of the instructor.

Thanks
 
I just spent 4 months taking a dotnet class where i learned very
little. One of the things I did not learn is this: What are the
dotnet equivilents of commands such as:

Adodc1.Recordset.AddNew
Adodc1.Recordset.Update
Adodc1.Recordset.MoveFirst
Adodc1.Recordset.MoveNext
Adodc1.Recordset.Delete

I understand how to connect to the database, set up the data
adapter, create a dataset, but USING any of this data in a practical
way seemed way beyond the knowledge of the instructor.

There are no connected Recordsets anymore. There is also no record pointer
anymore.

The result of a query can be read into a DataTable. You can access any
record in the DataTable by specifying the index of the record within the
DataTable.

A "replacement" for AddNew is the NewRow function of the DataTable. It
creates (surprise) a new row (=record). Then add the new row to the Rows
collection of the DataTable.
Calling the updating method of a DataAdapter synchronizes the DataTable with
the table in the database: Records added to the Datatable are inserted in
the database, records deleted are also deleted in the database, and modified
records are updated in the database. That's all done by Insert-, Update-,
and Delete-SQL statements executed by the DataAdapter.

But, why not read the ADO.NET documentation? There it is all explained in
detail.

http://msdn.microsoft.com/library/en-us/vbcon/html/vboriIntegratingDataVB.asp
http://msdn.microsoft.com/library/en-us/cpguide/html/cpconaccessingdatawithadonet.asp

For further ADO.NET related questions please turn to
microsoft.public.dotnet.framework.adonet.
 
Adodc1.Recordset.AddNew
Adodc1.Recordset.Update
Adodc1.Recordset.MoveFirst
Adodc1.Recordset.MoveNext
Adodc1.Recordset.Delete

Now I see you used a data control and are referring to data bound controls.
I can only provide a link for this:
http://msdn.microsoft.com/library/en-us/vbcon/html/vboriWindowsFormsDataArchitecture.asp
Still the other group mentioned is the better place to ask. For data binding
questions there is also
microsoft.public.dotnet.framework.windowsforms.databinding
 
Hi Tony,

I do this in addition to the answer from Armin

In my opinion also is the documentation is very much build on datareaders,
wizard and very few on using the dataset and the datatable.

I think because you are writing about the dataadapter you are talking about
the dataset and not the recordset. The answers are only ment to help you to
come on the route, and not complete just a comparising with the recordset
methods
Adodc1.Recordset.AddNew dataset.tables(0).rows.add(dataset.tables(0).newrow)

Adodc1.Recordset.Update
Dataadapter.update(dataset)
and beter is
Dataadapter.update(dataset.getchanges)
and even beter is
if dataset.haschanges
dataadapter.update(dataset.getchanges)
end if
(check what commando's you use with the dataset. there is a big difference
by instance with remove and delete, a removed datarow will not be updated).
Adodc1.Recordset.MoveFirst
dataset.tables(0).rows(0).item(0) is the first item in the first row.
Adodc1.Recordset.MoveNext
dataset.tables(0).rows(1).item(0) is the first item in the second row

Adodc1.Recordset.Delete
dataset.tables(0).rows(0).delete delete the first row

Is it not easy?

Cor
 
Hi Tony,

Before you understand this wrong,
In my opinion also is the documentation is very much build on datareaders,
wizard and very few on using the dataset and the datatable.

There is a lot of documentation about datasets and datatables in/on MSDN,
only in my opinion are the first pointers, specialy with walkthroughs and
things like that, very oriented onto wizards and datareaders.

But when you search you can find it

Cor
 
Back
Top