473,840 Members | 1,415 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

There is already an open DataReader associated with this Command..

Hello,

I have two Table Adapters that I am storing in a Cache using .NET 2.0 Web
Service and the Database is SQL Server on Windows 2003 IIS6.
Each of the two table adapters has its own Connection string.

The reason that table adapters are in cache is because I would like to
maintain the connection string that will not be closed for any Insert or
Update as there are thousands of requests per minutes to the WS.

Problems are that when calling Insert or Update from the table adapters I
received the error:
"There is already an open DataReader associated with this Command which must
be closed first" and then the table adapter that I called Insert or Update
from is remove from the Cache.
Thanks in advanced for any advice.
Asaf

Jan 19 '08 #1
11 3169
=?Utf-8?B?QXNhZg==?= <AG**@newsgroup s.nospamwrote in
news:B9******** *************** ***********@mic rosoft.com:
The reason that table adapters are in cache is because I would like to
maintain the connection string that will not be closed for any Insert
or Update as there are thousands of requests per minutes to the WS.
No need to do this, ADO.NET already provides connection pooling.
Maintaining a connection like this is generally inefficient. You should
open a connection at the last possible moment and close as early as
possible.

--
sp**********@ro gers.com (Do not e-mail)
Jan 19 '08 #2

"Asaf" <AG**@newsgroup s.nospamwrote in message
news:B9******** *************** ***********@mic rosoft.com...
Hello,

I have two Table Adapters that I am storing in a Cache using .NET 2.0 Web
Service and the Database is SQL Server on Windows 2003 IIS6.
Each of the two table adapters has its own Connection string.

The reason that table adapters are in cache is because I would like to
maintain the connection string that will not be closed for any Insert or
Update as there are thousands of requests per minutes to the WS.

Problems are that when calling Insert or Update from the table adapters I
received the error:
"There is already an open DataReader associated with this Command which
must
be closed first" and then the table adapter that I called Insert or Update
from is remove from the Cache.
Thanks in advanced for any advice.
http://msdn2.microsoft.com/en-us/library/8xx3tyca.aspx
Jan 19 '08 #3

"Asaf" <AG**@newsgroup s.nospamwrote in message
news:93******** *************** ***********@mic rosoft.com...
Hello,

I did a test with a web service to insert 100 records to DB when pressing
the Invoke button from IE.

When using this code:

TestTableAdapte r ta_Test = new TestTableAdapte r();
ta_Test.Connect ion.Open();

for (long i = 0; i < 100; i++)
{
ta_Test.Insert( i);
}

ta_Test.Connect ion.Close();

SQL Server 2005 Profiler shows "Audit Login" then the whole 100 records to
insert one by one "RPC:Comple ted" and then the "Audit Logout".
When using this code that suppose to use connection pooling:

TestTableAdapte r ta_Test = new TestTableAdapte r();

for (long i = 0; i < 100; i++)
{
ta_Test.Connect ion.Open();
ta_Test.Insert( i);
ta_Test.Connect ion.Close();
}

SQL Server 2005 Profiler shows "Audit Login" then insert one record
"RPC:Comple ted" and then the "Audit Logout" for each row, so there is an
Open
and Close connection for each row inserted to the DB.
Doesn’t it needs to pool a connection that is already opened and to
Login –
Logout for each inserted row?
Well #1, I wouldn't be using Table Adapters in a solution myself. I would
be using SQL Command Objects with a Stored Procedure, which is a faster
solution, because it would be a precompiled Stored Procedure that will stay
in memory based on the traffic you indicate.

As far as you trying to test the connection pooling, you should get with a
DBA and have he or she help you. Connection Pooling is there and it works,
which is a better solution, than what you're doing currently. You should let
ADO.NET, SQL Server and the O/S work for you.

Jan 20 '08 #4
Hi Arnold,

Why do I need a DBA?
Is there something to configure in SQL Server?
These two examples just show that Connection Pooling does not work or
connection pooling does not work with Table Adapters?

Thanks for your help but anyway I am still looking for a solution to this
problem so much appreciated if someone can advice me here.

Asaf
"Mr. Arnold" wrote:
>
"Asaf" <AG**@newsgroup s.nospamwrote in message
news:93******** *************** ***********@mic rosoft.com...
Hello,

I did a test with a web service to insert 100 records to DB when pressing
the Invoke button from IE.

When using this code:

TestTableAdapte r ta_Test = new TestTableAdapte r();
ta_Test.Connect ion.Open();

for (long i = 0; i < 100; i++)
{
ta_Test.Insert( i);
}

ta_Test.Connect ion.Close();

SQL Server 2005 Profiler shows "Audit Login" then the whole 100 records to
insert one by one "RPC:Comple ted" and then the "Audit Logout".
When using this code that suppose to use connection pooling:

TestTableAdapte r ta_Test = new TestTableAdapte r();

for (long i = 0; i < 100; i++)
{
ta_Test.Connect ion.Open();
ta_Test.Insert( i);
ta_Test.Connect ion.Close();
}

SQL Server 2005 Profiler shows "Audit Login" then insert one record
"RPC:Comple ted" and then the "Audit Logout" for each row, so there is an
Open
and Close connection for each row inserted to the DB.
Doesn’t it needs to pool a connection that is already opened and to
Login –
Logout for each inserted row?

Well #1, I wouldn't be using Table Adapters in a solution myself. I would
be using SQL Command Objects with a Stored Procedure, which is a faster
solution, because it would be a precompiled Stored Procedure that will stay
in memory based on the traffic you indicate.

As far as you trying to test the connection pooling, you should get with a
DBA and have he or she help you. Connection Pooling is there and it works,
which is a better solution, than what you're doing currently. You should let
ADO.NET, SQL Server and the O/S work for you.

Jan 20 '08 #5

"Asaf" <AG**@newsgroup s.nospamwrote in message
news:E8******** *************** ***********@mic rosoft.com...
Hi Arnold,

Why do I need a DBA?
Is there something to configure in SQL Server?
These two examples just show that Connection Pooling does not work or
connection pooling does not work with Table Adapters?
You do not know what you're talking about, and you need help. You need to
talk to a SQL Server Admin/DBA.
>
Thanks for your help but anyway I am still looking for a solution to this
problem so much appreciated if someone can advice me here.
You're not going to get the solution. You have been given the solution, but
you refuse to recognize it.

Jan 20 '08 #6
Hello Arnold,

You are saying very HARD words here and very scorn ones.
Please live this post to be answered by others who are willing to explain by
details.
Anyway thanks for you support.

Asaf
"Mr. Arnold" wrote:
>
"Asaf" <AG**@newsgroup s.nospamwrote in message
news:E8******** *************** ***********@mic rosoft.com...
Hi Arnold,

Why do I need a DBA?
Is there something to configure in SQL Server?
These two examples just show that Connection Pooling does not work or
connection pooling does not work with Table Adapters?

You do not know what you're talking about, and you need help. You need to
talk to a SQL Server Admin/DBA.

Thanks for your help but anyway I am still looking for a solution to this
problem so much appreciated if someone can advice me here.

You're not going to get the solution. You have been given the solution, but
you refuse to recognize it.

Jan 20 '08 #7
Sorry for the spelling mistakes, I meant "Leave" :)

"Mr. Arnold" wrote:
>
"Asaf" <AG**@newsgroup s.nospamwrote in message
news:E8******** *************** ***********@mic rosoft.com...
Hi Arnold,

Why do I need a DBA?
Is there something to configure in SQL Server?
These two examples just show that Connection Pooling does not work or
connection pooling does not work with Table Adapters?

You do not know what you're talking about, and you need help. You need to
talk to a SQL Server Admin/DBA.

Thanks for your help but anyway I am still looking for a solution to this
problem so much appreciated if someone can advice me here.

You're not going to get the solution. You have been given the solution, but
you refuse to recognize it.

Jan 20 '08 #8

"Asaf" <AG**@newsgroup s.nospamwrote in message
news:DA******** *************** ***********@mic rosoft.com...
Sorry for the spelling mistakes, I meant "Leave" :)

I don't think you own me or anything else.
If you don't want to read it then don't.
But it is what it is for you on this.
I guess the truth hurts.
Should I get you some tissues for your issues?

Jan 20 '08 #9

"Asaf" <AG**@newsgroup s.nospamwrote in message
news:2F******** *************** ***********@mic rosoft.com...
Hi All,

Will be much appreciated if someone can response with more details (not
the
Arnold way) why connection pooling is not working for my test table
adapters.
Why must you whine about it?

MS.Public.sqlse rver.connect -- forum.

Jan 20 '08 #10

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

Similar topics

20
7222
by: fniles | last post by:
I am using VB.NET 2003, SQL 2000, and SqlDataReader. As I read data from tblA, I want to populate tblB. I use SQLDataReader for both tables. I do not use thread. When I ExecuteReader on tblB, I get the error "There is already an open DataReader associated with this Connection which must be closed first." How can I fix this error ? For each DataReader, do I want to open and close the connection (in this case adoCon) to avoid this error ?...
10
6116
by: jimmy | last post by:
Hi again, sorry for posting two questions so close together but im working on a school project which is due in soon and running into some difficulties implementing the database parts. I have the code below which when executed generates the following error message: 'There is already an open datareader with this command which must be closed first' Private Sub MainMenu_Load(ByVal sender As System.Object, ByVal e As
13
3422
by: Bart | last post by:
Hi, i get the error: "There is already an open DataReader associated with this Command which must be closed first" Thanks Bart ----------------------------------------- Imports System.Data.sqlclient
3
13200
by: BLUE | last post by:
I've a TransactionScope in which I select some data and I want to do some queries for each record retrieved with my select. I'm using a DataReader and for each record I do factory.CreateCommand() and then I execute the command, but I get the following exception message: " There is already an open DataReader associated with this Command which must be closed first. " Searching on google I've found I've to create another connection, but...
0
9856
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9698
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10598
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10657
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9436
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7836
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5684
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5872
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4071
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.