Recordset vs Cursor

What's the difference between a recordset and cursor?
vbtigerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

LowfatspreadCommented:
a recordset may be implemented via a cursor
or someother means

a cursor is a Database object which allows the programmer to step throught the result set
and nake processing decisions based on the rows contained within it...

a recordset  is a result set returned to an external (to the database ) program
which the external program provides the capability to navigate...

hth

have you a specific scenario in mind?
0
nmcdermaidCommented:
Generally speaking you would use a cursor to scroll through a recordset.

A recordset usually refers to an entire set of rows, ie the result of a select from a table or from the SQL recordset functions. A recordset may have zero, one, or more rows.

A cursor is the is an object you can use to scroll through a recordset, allowing you to access one row at a time.

These words have slightly different meanings depending on whether you are using SQL-DMO, DTS, VB, T-SQL, etc.

You may wish to narrow your question down a bit.

0
ShogunWadeCommented:
Sounds to me like a homework question!
0
The Five Tenets of the Most Secure Backup

Data loss can hit a business in any number of ways. In reality, companies should expect to lose data at some point. The challenge is having a plan to recover from such an event.

vbtigerAuthor Commented:
Hi all,

Thanks for the quick response.  Actually,  I will be working on a new system based on VB + SQL Server.  I have only experience in developing applications with VB + Access.  I was reading through some articles on cursors and was wondering what the difference between an ADO recordset and cursor is.

BTW,  I need some info to get me started on SQL server.  Any links/pointers would be much appreciated.  I can increase the points if it is really worth it.

Thanks again!
0
ShogunWadeCommented:
I retract my comment then.

Basically as mentioned.   The results of a query are a set of records (ie recordset)  if you want to perform itterative operations on a set of records you need a "pointer" into the set. This "pointer" is a cursor and it allows you to navigate through a recordset pointing as a single row at any one time.

There are lots of different types of cursor.   You can for example set up cursors in SQL Server which arent exposed to a client application.  or you can set up a cursor on a client app by doing something like this

dim a as recordset
.....

a.open
...
cursor is not esablished.


a cursor generated on a client app can be client side or server side (this defines who is in charge of managing the pointer position (in a very simplistic sense))


Are you completely new to databases or have u had any SQL experience eg( oracle, sybase, MSAccess (lets pretend its sql), etc.)
0
ShogunWadeCommented:
oops prev post meant to say

 cursor is now esablished.

as opposed to

cursor is not esablished.

0
nmcdermaidCommented:
There is no ADO object called a cursor. Your question is a bit vague, what kind of cursor? I have explained generally the difference between a cursor and a recordset.

You can move through a recordset like a T-SQL cursor in ADO, but there is nothing called a cursor.

When you say Cursor possibly you mean the CursorLocation property? client and server cursors have their own advantages and disadvantages, but it is not something you need to worry about at this early stage.


I assume in Access you used the DAO library to access the DB

To use MS SQL through VB you will most likely be using the ADO library, which is slightly different to the DAO version, but recordsets mean the same thing in both libraries (though the objects are a bit different)

Someone else may be able to recommend a book or link to get you started with developing on SQL, but if you firstly check out the ADO help in VB that is a good start.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ShogunWadeCommented:
There are cursros in ADO!

Without cursors it is not possible to iterate through a recordset!

Cursors in ADO are implemented "behind the scenes"

when you open an ADO recordset you are implicitly establishing a cursor and on closing it you are destroying the cursor.

The existance of a cursor provides you with the ability to perform calls such as

.MoveFirst
.MoveLast
.MoveNext

etc.
0
nmcdermaidCommented:
Yes of course a cursor is implemented behind the scenes in ADO but as I said there is no ADO object called a cursor.


0
vbtigerAuthor Commented:
Hi ShogunWade,

I do have experience in developing applications with Access as backend and am also familiar with Oracle to a certain extent (PL/SQL).
0
ShogunWadeCommented:
"also familiar with Oracle "

ok SQL Server is pretty sumilar to oracle but there are differences.   for example

in SQL Server you can do:

SELECT 'fred'

which returns a recordset of 1 field with 1 value  'fred'

in oracle

you must do:

SELECT 'fred' FROM DUAL.

There are a numer of other differences but as you will see from above it is prodominently syntactical.    I would suggest scanning through sql books on line (commonly refered to as BOL) there are various simple examples in there as well as documentation.   Also look at the sample database Northwind or Pubs  both illustrate the basics of SQL Server.



0
vbtigerAuthor Commented:
0
vbtigerAuthor Commented:
Thanks guys!
0
vbtigerAuthor Commented:
From the same site:

When your application retrieves rows of data from SQL Server, it needs a place to store the rowset while it processes the information. An ADO Recordset object encapsulates the data and the operations allowed on that data. The Recordset object uses a cursor as a mechanism to organize the temporary storage. The cursor is similar to a dynamic array stored in memory, and the Recordset object is your interface to that array.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.