473,320 Members | 1,979 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Quick response somebody

I have an application which is multi-tiered. I want to return a
sqldatareader object from a function called in the data access tier. I know
that the preferred way of transferring data through tiers is with a dataset
but I want to use a datareader. My question is it possible to do this given
that the datareader object must remain connected to the database, so how
would I code the data access component correctly.

My first attempt failed because my code called the close method of the
sqlconnection object before returning the datareader abject.

However return the datreader from the data access layer without closing the
conncetion doesn't seem right.


Nov 15 '05 #1
3 1123
"Marinos Christoforou" <ma*****@globalit.com.cy> wrote in
news:uU**************@TK2MSFTNGP12.phx.gbl:

However return the datreader from the data access layer without
closing the conncetion doesn't seem right.


In the moment you close your connection you loose your datareader...

But your application design seems to be totaly screwed...
Just imagine what would happen if you'Re working with services Components
in a WebFarm...

It would be possible to pass a datareader, although you will need more than
one functions calls and you will have to call them in a specific order. All
in all this would be such a bad solution design that I can'T even tell you
how to do it ;-)

But if you really, really need it:

Create a Method that passes the datareader
Create a Method that initializes the datareader
Create a Method that cleans ip the datareader

Beware of multi-machine situations, and different user credentials etc..
'coz this would make the reader fail.

--
------ooo---OOO---ooo------

Peter Koen - www.kema.at
MCAD MCDBA MCT
CAI/RS CASE/RS IAT

------ooo---OOO---ooo------
Nov 15 '05 #2
Design issues aside you can also do the following which will close the
connection when the datareader is closed
assuming sqlCMD is a SqlCommand object

sqlCMD.ExecuteReader(System.Data.CommandBehavior.C loseConnection);

Chris Torgerson

"Marinos Christoforou" <ma*****@globalit.com.cy> wrote in message
news:uU**************@TK2MSFTNGP12.phx.gbl...
I have an application which is multi-tiered. I want to return a
sqldatareader object from a function called in the data access tier. I know that the preferred way of transferring data through tiers is with a dataset but I want to use a datareader. My question is it possible to do this given that the datareader object must remain connected to the database, so how
would I code the data access component correctly.

My first attempt failed because my code called the close method of the
sqlconnection object before returning the datareader abject.

However return the datreader from the data access layer without closing the conncetion doesn't seem right.

Nov 15 '05 #3
Thanks Peter,

Given the design issues, I would like to ask the following.

A dataReader is supposed to be fastest way to retrieve data espcially in
read-only data environments.

Applications are supposed to be multi-tiered, broken into layers that
handle the UI/Business/Data etc.

So how do you combine the two?

I suppose one way is to not return the DataReader object as such, but
instead the data in an array or list or another suitable container?

I am trying to feel my way into this area.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Paul | last post by:
I'm not getting the results I want when I use Response.Redirct in a ASP page. I enter this line of code in a asp page from domain1.com. Response.Redirect...
0
by: Navin | last post by:
hi, i am using the following code to generate a xls file using the content type now when the user opnes the file at his pc it takes long time to open..if the no of records in file is large...
1
by: YT | last post by:
Couple of quick ASP (3.0) Cookie questions: 1/ I'm using a cookie in my asp script to place cookies (within a key) so my code looks like: Response.Cookies( "quoteform" )( "name" ) = Session(...
6
by: Paolo | last post by:
Hello, I am getting no response when trying to connect to one of our databases. The funny thing is that it only happens when trying to connect using a specific user. Other users are able to...
1
by: Richard Holliingsworth | last post by:
Hello: Thanks for your quick response. I'm trying to import a new Excel file into an A2K table and it's truncating the data. One of the Excel columns is a text field that can be up to 2000...
5
by: David Thielen | last post by:
Hi; Almost all of the Quick Starts show the code in the .aspx file inside a <script> instead of in a seperate .aspx.cs file. My instinct is that the code should be in a seperate file to keep the...
55
by: Steven Nagy | last post by:
Hi all, Sorry I have no time to test this myself.... Can I add the same attribute to a field twice? Eg. Public string myField;
0
by: Chris Thomasson | last post by:
<wkaras@yahoo.comwrote in message news:1156863246.290976.191710@i3g2000cwc.googlegroups.com... volatile has nothing to do with the memory model... Well, except in Microsoft... ...
1
by: DILA | last post by:
Hi, I have included an embedded Real Player and an embedded Quick Time Player for streaming videos, in my web pages. I'm interested in searching for a method or a script to disable the...
3
by: homec | last post by:
Hi, I have included an embedded Real Player and an embedded Quick Time Player for streaming videos, in my web pages. I'm interested in searching for a method or a script to disable the ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.