Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

diffrence between OleDBDataAdapter and OleDBDataReader, return info to the UI

1,242 views
Skip to first unread message

Icedragon

unread,
Feb 16, 2002, 8:52:09 PM2/16/02
to
Ok I have been reading up on the diffrence between OleDBDataAdapter and
OleDBDataReader.
I have been on MSDN library and they dont really explain the full diffrence.
What I am looking for is which one is better for me. Link the db to the
grid by SQL statement. And allow the user to edit/update/add/delete records.
Everytime the user scrolls/click through the dbgrid the data will be
displayed in textboxes below to allow data manipulation.

I have tried to retreive info but I am unable to. But I am able to connect
to the DB.


Don Jelley

unread,
Feb 16, 2002, 9:34:19 PM2/16/02
to
OleDBDataReader is meant to replace a "firehose cursor" - data is read-only.
The OleDBDataReader is more flexible (and expensive), but it is what you
need if you want to modify the data.

"Icedragon" <ryka...@home.com> wrote in message
news:#8T29V1tBHA.2056@tkmsftngp03...

Aravind C

unread,
Feb 16, 2002, 9:41:15 PM2/16/02
to
Hi IceDragon,

AFAIK, looks like OleDBDataAdapter would be a better
choice for the application type that you describe.
Though OleDBDataReader is certainly more lightweight
than the OleDBDataAdapter, you'd use it when you need
to navigate the recordset with foward-only, read-only access.
Since you need to modify the data source as well,
OleDBDataAdapter would be the way to go.

Regards,
Aravind C


"Icedragon" <ryka...@home.com> wrote in message
news:#8T29V1tBHA.2056@tkmsftngp03...

Don Jelley

unread,
Feb 16, 2002, 10:04:49 PM2/16/02
to
Ooops! I meant to say that the OleDBDataADAPTER is more flexible, sorry!


"Icedragon" <ryka...@home.com> wrote in message
news:#8T29V1tBHA.2056@tkmsftngp03...

SONALI.NET

unread,
Feb 17, 2002, 1:46:57 AM2/17/02
to
Hi
 
The working of OLEDBDataAdapter and OLDBDataReader is different
Both are meant to retrieve the data.
  • OLEDBDataReader is like "Forward-Only Cursor". So you cannot do and edit/insert/delete with DataReader. In any case where you want to acces the data faster you would go ahead and use a DataReader
  • OLEDBDataAdapter is the one which gives Flexibility to edit/Delete/insert the data. In comparision with DataReader you would find a DataAdapter slower.
The code statements itself suggest that DataReader maintains always a connection between the DataTier where as DataAdapater acts like disconnected Recordset
Your scenerio the best suited is making use of a DataAdapter.
 
 
For DataAdapater code is:
myda = new OLEDBDataAdapter("Select * from MyTable" , myconnection)
ds = new dataset()
'Dataset is filled by the dataAdapter
myda.fill(ds, "MyTable")
'Your dataset talks to the Presentation Tier not your DataAdapter
'The DataAdapter serves as a bridge between a DataSet and a data source for retrieving and saving data
DataGrid1.datasource = ds.tables("MyTable")
'in case of webform
'DataGrid1.Databind()
 
For DataReader Code is :
myCmd =  new OLEDBCommand("Select * from MyTable" , myconnection)
'myReader is declared as oledbdatareader
myReader = myCmd.ExecuteReader
'Here the datareader is directly used to fetch the data
while not myReader.Read
    Console.writeline(myReader("Field1"))
end while
 
Regards
Sushila
 
 
In your case
"Icedragon" <ryka...@home.com> wrote in message news:#8T29V1tBHA.2056@tkmsftngp03...

Akila.NET

unread,
Feb 17, 2002, 2:30:24 AM2/17/02
to
Hi,

ADO.NET is a deliberate attempt to encourage developers to use the
disconnected model as disconnected data is more scalable because it reduces
the demand on database servers.
The DataSet is an in-memory cache of data retrieved from a database and
process it in a DISCONNECTED fashion.
DataSets are the result of bringing together ADO and XML. A DataSet does
not know about databases or SQL. There are two standard ways of getting
tables of data into a DataSet, One is by using a 'OleDBDataAdapter' object
that turns the results of a database query into XML.
The second is to work directly Read and Write XML data and schemas, and can
work closely with an XMLDataDocument object.
The OleDbDataAdapter acts as an interface between the DataSet & the
underlying databace for any data retrieval, updation, or deletion.

OledbDataReader class offers higher performance than the DataSet class
because OledbDataReader reads data directly from a database connection.

There are two main situations where you would consider using DataReaders.
If you use an application development model where you hand-code your user
interface rather than use data binding, and hand-code your updates using SQL
or stored procedures, then the DataReader provides an efficient tool for
accessing relational data. For everyone else, DataReaders are useful where
processing requires that you look up state held in a database, but you don't
need scrolling, binding, XML or automatic updating capabilities. Good
examples include populating a list or validating a product code.

Regards
Akila
http://www.Synergetics-India.com


"Icedragon" <ryka...@home.com> wrote in message
news:#8T29V1tBHA.2056@tkmsftngp03...

Bipin

unread,
Feb 17, 2002, 3:36:32 AM2/17/02
to
Hi,
The choice of dataadpter(DataSet actually) or datareader depends on the kind
of application you are using.
- DataReader is more efficiant than DataSet because of lower overheads.
- If you are developing ASP.NET application many times DataReader is a
better choice.
- However, if you are working with 'batch updates' kind of applications then
DataSet is preferred.
- Windows clients can easily use disconnected behavior of DataSet as there
are no issues of state maintenance.
- In cases where you are passing data across tires, DataSet is recommended
way.

Thanks.
Bipin Joshi
-------------------------------------
Software Developer | Author
.Net Simplified @ Bipin Joshi.com
http://www.bipinjoshi.com
-------------------------------------


"Icedragon" <ryka...@home.com> wrote in message
news:#8T29V1tBHA.2056@tkmsftngp03...

santu sen

unread,
Feb 17, 2002, 12:56:39 PM2/17/02
to
hi,
OleDBDataReader is used for read-only purpose,here you can't
edit,insert,delete but only read. But this one is faster when u need to
access data only for read purpose. datareader maintains a constant
connection with the database.

Whereas, OLEDBDataAdapter is used when u want to work on the data like
edit,insert,delete. its more better as u have the flexibility/option to work
on the data though its slow but its a lot useful, moreover it acts like
disconnected recordset.

which one is better depends on your application & what u want. if you give
the user full access of ur data, adapter is good otherwise for viewing/data
retrieve on reader is good.

there are several issues & details related to ADO.NET & XML data access
methods are avaibale.If you need more help, you can mail me.

bye,
santu


0 new messages