473,326 Members | 2,048 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,326 software developers and data experts.

Re: About SQLDataReader

On Apr 19, 7:20*am, "Tony Johansson" <johansson.anders...@telia.com>
wrote:
I'm pretty sure that if you haven't an open a database connection when you
want to get something from the database a connection is temporarily open for
you and when you have got the data the connection is closed(returned to the
pool).
I believe that's the case for SqlDataAdapter, but I can't see any
documentation saying it's the case for calling
SqlCommand.ExecuteReader directly.

Jon
Jun 27 '08 #1
3 1033
Jon Skeet [C# MVP] wrote:
On Apr 19, 7:20 am, "Tony Johansson" <johansson.anders...@telia.com>
wrote:
>I'm pretty sure that if you haven't an open a database connection when you
want to get something from the database a connection is temporarily open for
you and when you have got the data the connection is closed(returned to the
pool).

I believe that's the case for SqlDataAdapter, but I can't see any
documentation saying it's the case for calling
SqlCommand.ExecuteReader directly.
The reader has to support data sizes that can not be in memory,
so ExecuteReader can not release the connection.

..ExecuteReader(CommandBehavior.CloseConnection) must be the
closest.

Arne
Jun 27 '08 #2
On Apr 19, 9:05*am, Arne Vajhøj <a...@vajhoej.dkwrote:
I believe that's the case for SqlDataAdapter, but I can't see any
documentation saying it's the case for calling
SqlCommand.ExecuteReader directly.

The reader has to support data sizes that can not be in memory,
so ExecuteReader can not release the connection.
When the reader is closed, I think it's reasonable for it to close the
connection when CommandBehavior.CloseConnection has been specified -
I'd certainly expect to have to retrieve all the data I wanted (even
from blobs/clobs) before that point.

However, I believe the OP is more concerned that it's not *opening*
the connection.

Jon
Jun 27 '08 #3
Jon Skeet [C# MVP] wrote:
On Apr 19, 9:05 am, Arne Vajhøj <a...@vajhoej.dkwrote:
>>I believe that's the case for SqlDataAdapter, but I can't see any
documentation saying it's the case for calling
SqlCommand.ExecuteReader directly.
The reader has to support data sizes that can not be in memory,
so ExecuteReader can not release the connection.

When the reader is closed, I think it's reasonable for it to close the
connection when CommandBehavior.CloseConnection has been specified -
I'd certainly expect to have to retrieve all the data I wanted (even
from blobs/clobs) before that point.

However, I believe the OP is more concerned that it's not *opening*
the connection.
Ah. Then everything makes sense.

Arne
Jun 27 '08 #4

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

Similar topics

3
by: Ricola ! | last post by:
Why do I say: SqlDataReader dr; instead of SqlDataReader dr = new SqlDataReader();
7
by: Franck Diastein | last post by:
Hi, when I call ExportData I have this error: Invalid attempt to Read when reader is closed. Telling me that there's a problem with this line: while(_dataR.Read()){ Code:...
3
by: Neil Guyette | last post by:
Hello, Everyone, I'm trying to find information on how to populate a combo box using a SqlDataReader. I want to be able to set the value of the combo's value property different then the...
1
by: Arvind P Rangan | last post by:
Hi All, How do you get all the values of a sqldatareader if it contains multiple resultset. Using sqldatareader.nextresult and sqldatareader.read e.g. While sqldatareader.read ' If not...
4
by: Michael Carr | last post by:
I have a function that populates a class with values from a database. I'd like to pass into the function either a SqlDataReader or a DataRow, depending on which mechanism I'm using to retrieve data...
1
by: me | last post by:
Why is SqlDataReader not present in visual studios Toolbox->Data where I find components like DataSet? Most examples in books and in vs.net are based on datasets but using disconnected tables seems...
8
by: bidllc | last post by:
I have a funtion that works fine and dandy when called from anywhere in my app. It will NOT work when called from inside the class in which it resides. This is the function I'm calling:...
4
by: mimi | last post by:
Hi Please help me out, I can't find a way to close a sqldatareader when error occur at statement cmd.ExecuteReader(). I can't close it in catch because it is local in try scope and I can't...
7
by: Web learner | last post by:
I am trying to create a method GetDataFor(string column) becaues I have to repeat the same statements for several columns but I get an error as follows: The name 'dr' does not exist in the current...
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...
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

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.