By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,846 Members | 1,252 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,846 IT Pros & Developers. It's quick & easy.

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

P: n/a

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

Nov 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
<to**************@hotmail.com> schrieb

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...tingDataVB.asp
http://msdn.microsoft.com/library/en...withadonet.asp

For further ADO.NET related questions please turn to
microsoft.public.dotnet.framework.adonet.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2

P: n/a
Cor
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).newro w)
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

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

Nov 20 '05 #3

P: n/a
<to**************@hotmail.com> schrieb

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...chitecture.asp
Still the other group mentioned is the better place to ask. For data binding
questions there is also
microsoft.public.dotnet.framework.windowsforms.dat abinding
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #4

P: n/a
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
Nov 20 '05 #5

P: n/a
Hi,

VBTV episode 4 has some good info on ADO.NET
http://msdn.microsoft.com/vbtv/

Ken
-------------------
<to**************@hotmail.com> wrote in message
news:n4********************************@4ax.com...

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

Nov 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.