473,769 Members | 3,350 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 3165
=?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
7215
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
6110
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
3415
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
13196
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
9590
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, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9424
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
10223
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10051
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...
0
9866
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5310
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...
1
3968
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.