PC Review


Reply
Thread Tools Rate Thread

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

 
 
tony010409020622@hotmail.com
Guest
Posts: n/a
 
      16th Dec 2003

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

 
Reply With Quote
 
 
 
 
Armin Zingler
Guest
Posts: n/a
 
      16th Dec 2003
<(E-Mail Removed)> 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

 
Reply With Quote
 
Armin Zingler
Guest
Posts: n/a
 
      16th Dec 2003
<(E-Mail Removed)> 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.databinding


--
Armin

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

 
Reply With Quote
 
Cor
Guest
Posts: n/a
 
      16th Dec 2003
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

>
> 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
>



 
Reply With Quote
 
Cor
Guest
Posts: n/a
 
      16th Dec 2003
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


 
Reply With Quote
 
Ken Tucker [MVP]
Guest
Posts: n/a
 
      16th Dec 2003
Hi,

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

Ken
-------------------
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> 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
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sobre el recordset.movefirst !00000 Microsoft Access 1 23rd Jul 2007 03:46 AM
movefirst returns last recordset http Microsoft Access VBA Modules 1 2nd Mar 2007 09:24 PM
How to loop through a recordset and update the field of a recordset or delete current record Karen Middleton Microsoft Access Macros 1 4th Jan 2005 10:30 AM
Invalid Operation on recordset.movefirst Brad Microsoft Access VBA Modules 3 8th Jan 2004 03:47 AM
AddNew, Update and Delete Chris Coghlan Microsoft Access Queries 0 7th Oct 2003 01:17 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:36 AM.