473,386 Members | 1,673 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,386 software developers and data experts.

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 3123
=?Utf-8?B?QXNhZg==?= <AG**@newsgroups.nospamwrote in
news:B9**********************************@microsof t.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**********@rogers.com (Do not e-mail)
Jan 19 '08 #2

"Asaf" <AG**@newsgroups.nospamwrote in message
news:B9**********************************@microsof t.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**@newsgroups.nospamwrote in message
news:93**********************************@microsof t.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:

TestTableAdapter ta_Test = new TestTableAdapter();
ta_Test.Connection.Open();

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

ta_Test.Connection.Close();

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

TestTableAdapter ta_Test = new TestTableAdapter();

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

SQL Server 2005 Profiler shows "Audit Login" then insert one record
"RPC:Completed" 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**@newsgroups.nospamwrote in message
news:93**********************************@microsof t.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:

TestTableAdapter ta_Test = new TestTableAdapter();
ta_Test.Connection.Open();

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

ta_Test.Connection.Close();

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

TestTableAdapter ta_Test = new TestTableAdapter();

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

SQL Server 2005 Profiler shows "Audit Login" then insert one record
"RPC:Completed" 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**@newsgroups.nospamwrote in message
news:E8**********************************@microsof t.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**@newsgroups.nospamwrote in message
news:E8**********************************@microsof t.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**@newsgroups.nospamwrote in message
news:E8**********************************@microsof t.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**@newsgroups.nospamwrote in message
news:DA**********************************@microsof t.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**@newsgroups.nospamwrote in message
news:2F**********************************@microsof t.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.sqlserver.connect -- forum.

Jan 20 '08 #10
"Mr. Arnold" <MR. Ar****@Arnold.comwrote in
news:eT**************@TK2MSFTNGP02.phx.gbl:
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 a note, it's a religious debate between inline SQL and stored
procedures. As far as I'm aware, the performance gain by using SPs is
minimal, hence I prefer to use inline SQL (no need to load SQL onto a
server, and everything is contained within the application.
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.


--
sp**********@rogers.com (Do not e-mail)
Jan 20 '08 #11
=?Utf-8?B?QXNhZg==?= <AG**@newsgroups.nospamwrote in
news:93**********************************@microsof t.com:
When using this code that suppose to use connection pooling:

TestTableAdapter ta_Test = new TestTableAdapter();

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

SQL Server 2005 Profiler shows "Audit Login" then insert one record
"RPC:Completed" and then the "Audit Logout" for each row, so there is
an Open and Close connection for each row inserted to the DB.
A connection pool is created for each unique connection string. When a
pool is created, multiple connection objects are created and added to
the pool so that the minimum pool size requirement is satisfied.
Connections are added to the pool as needed, up to the maximum pool
size.

http://msdn2.microsoft.com/en-us/lib...ca(vs.71).aspx

FYI, in the maximum pool size just happens to be 100 connections... Try
your test again with 500 - 1000 interations.
--
sp**********@rogers.com (Do not e-mail)
Jan 20 '08 #12

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

Similar topics

20
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...
10
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...
13
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...
3
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()...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...

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.