I am using VB.NET 2003 and SQL 2005.
To use connection pooling and avoid the error "There is already an open
DataReader associated with this Connection which must be closed first." , I
understand that I want to release/close connections in a timely fashion.
What I do is I declare the SqlClient.SqlConnection variable as a local
variable inside my subroutine (instead of a global variable). Right before I
Fill the dataset I open the connection, and right after I fill the dataset I
close the connection, like shown below. Do I do it correctly ? Thank you.
sub MySub
Dim adoCon As SqlClient.SqlConnection
Dim cmdSQL As SqlClient.SqlCommand
Dim dsSQL As DataSet
Dim daSQL As SqlClient.SqlDataAdapter
adoCon = New SqlClient.SqlConnection
With adoCon
.ConnectionString = DB_Path
.Open() '--open connection
End With
cmdSQL = New SqlClient.SqlCommand
With cmdSQL
.Connection = adoCon
.CommandText = sSQL
End With
daSQL = New SqlClient.SqlDataAdapter
dsSQL = New DataSet
daSQL.SelectCommand = m_cmdSQL
daSQL.Fill(m_dsSQL) '--fill dataset
If Not adoCon Is Nothing Then
adoCon.Close() '--close connection
adoCon = Nothing
End If 9 4749
I get the same message a couple of weeks ago.
You can use the MultipleActiveResultSets on your connection string so you
don't have to close a DataReader (or whatever) first to be able to go for
the next one.
see this link with information about it: http://msdn2.microsoft.com/en-us/lib...esultsets.aspx
Hope it helps.
Best regards,
Carlos Camargo
"fniles" <fn****@pfmail.comescribió en el mensaje
news:uy*************@TK2MSFTNGP05.phx.gbl...
>I am using VB.NET 2003 and SQL 2005.
To use connection pooling and avoid the error "There is already an open
DataReader associated with this Connection which must be closed first." ,
I understand that I want to release/close connections in a timely fashion.
What I do is I declare the SqlClient.SqlConnection variable as a local
variable inside my subroutine (instead of a global variable). Right before
I Fill the dataset I open the connection, and right after I fill the
dataset I close the connection, like shown below. Do I do it correctly ?
Thank you.
sub MySub
Dim adoCon As SqlClient.SqlConnection
Dim cmdSQL As SqlClient.SqlCommand
Dim dsSQL As DataSet
Dim daSQL As SqlClient.SqlDataAdapter
adoCon = New SqlClient.SqlConnection
With adoCon
.ConnectionString = DB_Path
.Open() '--open connection
End With
cmdSQL = New SqlClient.SqlCommand
With cmdSQL
.Connection = adoCon
.CommandText = sSQL
End With
daSQL = New SqlClient.SqlDataAdapter
dsSQL = New DataSet
daSQL.SelectCommand = m_cmdSQL
daSQL.Fill(m_dsSQL) '--fill dataset
If Not adoCon Is Nothing Then
adoCon.Close() '--close connection
adoCon = Nothing
End If
Thank you.
Does it mean that if I set MultipleActiveResultSets to true, I can have more
than 1 DataReader open in the connection ?
Regarding using a local SQLConnection variable (instead of using a global
one) and set it to new, open and close the connection everytime I fill a
dataset, is it correct ?
Or, do I need to use a global SQLConnection variable
1. new and open it on form_load (and do not close this one until
form_Closed)
2. and in each subroutine use this global SQLConnection variable but new,
open and close the connection in this subroutine ?
"Carlos Camargo" <cc******@INVALID.yahoo.comwrote in message
news:um**************@TK2MSFTNGP06.phx.gbl...
>I get the same message a couple of weeks ago.
You can use the MultipleActiveResultSets on your connection string so you
don't have to close a DataReader (or whatever) first to be able to go for
the next one.
see this link with information about it: http://msdn2.microsoft.com/en-us/lib...esultsets.aspx
Hope it helps.
Best regards,
Carlos Camargo
"fniles" <fn****@pfmail.comescribió en el mensaje
news:uy*************@TK2MSFTNGP05.phx.gbl...
>>I am using VB.NET 2003 and SQL 2005. To use connection pooling and avoid the error "There is already an open DataReader associated with this Connection which must be closed first." , I understand that I want to release/close connections in a timely fashion. What I do is I declare the SqlClient.SqlConnection variable as a local variable inside my subroutine (instead of a global variable). Right before I Fill the dataset I open the connection, and right after I fill the dataset I close the connection, like shown below. Do I do it correctly ? Thank you.
sub MySub Dim adoCon As SqlClient.SqlConnection Dim cmdSQL As SqlClient.SqlCommand Dim dsSQL As DataSet Dim daSQL As SqlClient.SqlDataAdapter
adoCon = New SqlClient.SqlConnection With adoCon .ConnectionString = DB_Path .Open() '--open connection End With cmdSQL = New SqlClient.SqlCommand With cmdSQL .Connection = adoCon .CommandText = sSQL End With daSQL = New SqlClient.SqlDataAdapter dsSQL = New DataSet daSQL.SelectCommand = m_cmdSQL daSQL.Fill(m_dsSQL) '--fill dataset If Not adoCon Is Nothing Then adoCon.Close() '--close connection adoCon = Nothing End If
Also, when I set my connection string to the following
Data Source=mySQL2005;Initial Catalog=myDB;User
ID=myUserID;Password=myPass;MultipleActiveResultSe ts=True
I got the error "Keyword not supported: 'multipleactiveresultsets'.
Dim adoCon As SqlClient.SqlConnection
With adoCon
.ConnectionString = DB_Path -->>error here
.Open()
End With
"Carlos Camargo" <cc******@INVALID.yahoo.comwrote in message
news:um**************@TK2MSFTNGP06.phx.gbl...
>I get the same message a couple of weeks ago.
You can use the MultipleActiveResultSets on your connection string so you
don't have to close a DataReader (or whatever) first to be able to go for
the next one.
see this link with information about it: http://msdn2.microsoft.com/en-us/lib...esultsets.aspx
Hope it helps.
Best regards,
Carlos Camargo
"fniles" <fn****@pfmail.comescribió en el mensaje
news:uy*************@TK2MSFTNGP05.phx.gbl...
>>I am using VB.NET 2003 and SQL 2005. To use connection pooling and avoid the error "There is already an open DataReader associated with this Connection which must be closed first." , I understand that I want to release/close connections in a timely fashion. What I do is I declare the SqlClient.SqlConnection variable as a local variable inside my subroutine (instead of a global variable). Right before I Fill the dataset I open the connection, and right after I fill the dataset I close the connection, like shown below. Do I do it correctly ? Thank you.
sub MySub Dim adoCon As SqlClient.SqlConnection Dim cmdSQL As SqlClient.SqlCommand Dim dsSQL As DataSet Dim daSQL As SqlClient.SqlDataAdapter
adoCon = New SqlClient.SqlConnection With adoCon .ConnectionString = DB_Path .Open() '--open connection End With cmdSQL = New SqlClient.SqlCommand With cmdSQL .Connection = adoCon .CommandText = sSQL End With daSQL = New SqlClient.SqlDataAdapter dsSQL = New DataSet daSQL.SelectCommand = m_cmdSQL daSQL.Fill(m_dsSQL) '--fill dataset If Not adoCon Is Nothing Then adoCon.Close() '--close connection adoCon = Nothing End If
Regarding MultipleActiveResultSets, that's right, set it to True and your
may be able to have more than a DataReader open at the same time, just
remember to close them anyway so the system behaves nicely with resources
like memory usage, processor, network and so on.
Regarding the issue of using a local or global connection, it will depend on
your application, but if the application is moderate or intensive in its use
of database, then I will recomend to use a global connection.
You may want to take a look at the Database Application Block from the
Microsoft Enterprise Library 3.0 (it's free -$0.00- !!!). It makes things a
little bit easier to access the database and you don't have to control the
connection state yourself (it handles the connection state, a connection
pool, and so on): http://msdn2.microsoft.com/en-us/library/aa480453.aspx
Hope this helps,
Carlos Camargo
"fniles" <fn****@pfmail.comescribió en el mensaje
news:uF****************@TK2MSFTNGP06.phx.gbl...
Thank you.
Does it mean that if I set MultipleActiveResultSets to true, I can have
more than 1 DataReader open in the connection ?
Regarding using a local SQLConnection variable (instead of using a global
one) and set it to new, open and close the connection everytime I fill a
dataset, is it correct ?
Or, do I need to use a global SQLConnection variable
1. new and open it on form_load (and do not close this one until
form_Closed)
2. and in each subroutine use this global SQLConnection variable but new,
open and close the connection in this subroutine ?
"Carlos Camargo" <cc******@INVALID.yahoo.comwrote in message
news:um**************@TK2MSFTNGP06.phx.gbl...
>>I get the same message a couple of weeks ago.
You can use the MultipleActiveResultSets on your connection string so you don't have to close a DataReader (or whatever) first to be able to go for the next one.
see this link with information about it: http://msdn2.microsoft.com/en-us/lib...esultsets.aspx
Hope it helps.
Best regards,
Carlos Camargo
"fniles" <fn****@pfmail.comescribió en el mensaje news:uy*************@TK2MSFTNGP05.phx.gbl...
>>>I am using VB.NET 2003 and SQL 2005. To use connection pooling and avoid the error "There is already an open DataReader associated with this Connection which must be closed first." , I understand that I want to release/close connections in a timely fashion. What I do is I declare the SqlClient.SqlConnection variable as a local variable inside my subroutine (instead of a global variable). Right before I Fill the dataset I open the connection, and right after I fill the dataset I close the connection, like shown below. Do I do it correctly ? Thank you.
sub MySub Dim adoCon As SqlClient.SqlConnection Dim cmdSQL As SqlClient.SqlCommand Dim dsSQL As DataSet Dim daSQL As SqlClient.SqlDataAdapter
adoCon = New SqlClient.SqlConnection With adoCon .ConnectionString = DB_Path .Open() '--open connection End With cmdSQL = New SqlClient.SqlCommand With cmdSQL .Connection = adoCon .CommandText = sSQL End With daSQL = New SqlClient.SqlDataAdapter dsSQL = New DataSet daSQL.SelectCommand = m_cmdSQL daSQL.Fill(m_dsSQL) '--fill dataset If Not adoCon Is Nothing Then adoCon.Close() '--close connection adoCon = Nothing End If
Thank you.
If I use a global variable, does it mean that
1. I set it to new and open it on main form_load (and do not close this one
until form_Closed)
2. and in each subroutine use this global SQLConnection variable but set it
to new, open and close this connection in this subroutine ?
or,
simply in each subroutine use this global SQLConnection variable but set it
to new, open and close this connection in this subroutine, and do not need
to open it in the main form_load ?
"Carlos Camargo" <cc******@INVALID.yahoo.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Regarding MultipleActiveResultSets, that's right, set it to True and your
may be able to have more than a DataReader open at the same time, just
remember to close them anyway so the system behaves nicely with resources
like memory usage, processor, network and so on.
Regarding the issue of using a local or global connection, it will depend
on your application, but if the application is moderate or intensive in
its use of database, then I will recomend to use a global connection.
You may want to take a look at the Database Application Block from the
Microsoft Enterprise Library 3.0 (it's free -$0.00- !!!). It makes things
a little bit easier to access the database and you don't have to control
the connection state yourself (it handles the connection state, a
connection pool, and so on):
http://msdn2.microsoft.com/en-us/library/aa480453.aspx
Hope this helps,
Carlos Camargo
"fniles" <fn****@pfmail.comescribió en el mensaje
news:uF****************@TK2MSFTNGP06.phx.gbl...
>Thank you. Does it mean that if I set MultipleActiveResultSets to true, I can have more than 1 DataReader open in the connection ?
Regarding using a local SQLConnection variable (instead of using a global one) and set it to new, open and close the connection everytime I fill a dataset, is it correct ? Or, do I need to use a global SQLConnection variable 1. new and open it on form_load (and do not close this one until form_Closed) 2. and in each subroutine use this global SQLConnection variable but new, open and close the connection in this subroutine ?
"Carlos Camargo" <cc******@INVALID.yahoo.comwrote in message news:um**************@TK2MSFTNGP06.phx.gbl...
>>>I get the same message a couple of weeks ago.
You can use the MultipleActiveResultSets on your connection string so you don't have to close a DataReader (or whatever) first to be able to go for the next one.
see this link with information about it: http://msdn2.microsoft.com/en-us/lib...esultsets.aspx
Hope it helps.
Best regards,
Carlos Camargo
"fniles" <fn****@pfmail.comescribió en el mensaje news:uy*************@TK2MSFTNGP05.phx.gbl... I am using VB.NET 2003 and SQL 2005. To use connection pooling and avoid the error "There is already an open DataReader associated with this Connection which must be closed first." , I understand that I want to release/close connections in a timely fashion. What I do is I declare the SqlClient.SqlConnection variable as a local variable inside my subroutine (instead of a global variable). Right before I Fill the dataset I open the connection, and right after I fill the dataset I close the connection, like shown below. Do I do it correctly ? Thank you.
sub MySub Dim adoCon As SqlClient.SqlConnection Dim cmdSQL As SqlClient.SqlCommand Dim dsSQL As DataSet Dim daSQL As SqlClient.SqlDataAdapter
adoCon = New SqlClient.SqlConnection With adoCon .ConnectionString = DB_Path .Open() '--open connection End With cmdSQL = New SqlClient.SqlCommand With cmdSQL .Connection = adoCon .CommandText = sSQL End With daSQL = New SqlClient.SqlDataAdapter dsSQL = New DataSet daSQL.SelectCommand = m_cmdSQL daSQL.Fill(m_dsSQL) '--fill dataset If Not adoCon Is Nothing Then adoCon.Close() '--close connection adoCon = Nothing End If
fniles,
MARS is a .Net 2 feature. You would need to use VS 2005 to have access to it.
I will also mention that using MARS is more involved than just turning it on
in the connection string. MARS has all sorts of ramifications that you need
to understand really well before using it.
Kerry Moorman
"fniles" wrote:
Also, when I set my connection string to the following
Data Source=mySQL2005;Initial Catalog=myDB;User
ID=myUserID;Password=myPass;MultipleActiveResultSe ts=True
I got the error "Keyword not supported: 'multipleactiveresultsets'.
Dim adoCon As SqlClient.SqlConnection
With adoCon
.ConnectionString = DB_Path -->>error here
.Open()
End With
"Carlos Camargo" <cc******@INVALID.yahoo.comwrote in message
news:um**************@TK2MSFTNGP06.phx.gbl...
I get the same message a couple of weeks ago.
You can use the MultipleActiveResultSets on your connection string so you
don't have to close a DataReader (or whatever) first to be able to go for
the next one.
see this link with information about it: http://msdn2.microsoft.com/en-us/lib...esultsets.aspx
Hope it helps.
Best regards,
Carlos Camargo
"fniles" <fn****@pfmail.comescribió en el mensaje
news:uy*************@TK2MSFTNGP05.phx.gbl...
>I am using VB.NET 2003 and SQL 2005.
To use connection pooling and avoid the error "There is already an open
DataReader associated with this Connection which must be closed first." ,
I understand that I want to release/close connections in a timely
fashion. What I do is I declare the SqlClient.SqlConnection variable as a
local variable inside my subroutine (instead of a global variable). Right
before I Fill the dataset I open the connection, and right after I fill
the dataset I close the connection, like shown below. Do I do it
correctly ? Thank you.
sub MySub
Dim adoCon As SqlClient.SqlConnection
Dim cmdSQL As SqlClient.SqlCommand
Dim dsSQL As DataSet
Dim daSQL As SqlClient.SqlDataAdapter
adoCon = New SqlClient.SqlConnection
With adoCon
.ConnectionString = DB_Path
.Open() '--open connection
End With
cmdSQL = New SqlClient.SqlCommand
With cmdSQL
.Connection = adoCon
.CommandText = sSQL
End With
daSQL = New SqlClient.SqlDataAdapter
dsSQL = New DataSet
daSQL.SelectCommand = m_cmdSQL
daSQL.Fill(m_dsSQL) '--fill dataset
If Not adoCon Is Nothing Then
adoCon.Close() '--close connection
adoCon = Nothing
End If
Open the connection in your application's entry point, for example in the
Load event for the main form, and store the resulting connection object in a
global variable.
Close it when that same form gets closed.
In individual procedures where you go for some info from the database or
update data there, just send the querys and get the results, don't open the
connection and close it again, because doing that (open and close
connections all the time) will make your application somehow slow because
opening the connection involves a relatively-heavy process for both, the
server computer and the client computer. Once a connection gets stablished
things will go faster.
Best regards,
Carlos Camargo
"fniles" <fn****@pfmail.comescribió en el mensaje
news:ew**************@TK2MSFTNGP03.phx.gbl...
Thank you.
If I use a global variable, does it mean that
1. I set it to new and open it on main form_load (and do not close this
one until form_Closed)
2. and in each subroutine use this global SQLConnection variable but set
it to new, open and close this connection in this subroutine ?
or,
simply in each subroutine use this global SQLConnection variable but set
it to new, open and close this connection in this subroutine, and do not
need to open it in the main form_load ?
"Carlos Camargo" <cc******@INVALID.yahoo.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>Regarding MultipleActiveResultSets, that's right, set it to True and your may be able to have more than a DataReader open at the same time, just remember to close them anyway so the system behaves nicely with resources like memory usage, processor, network and so on.
Regarding the issue of using a local or global connection, it will depend on your application, but if the application is moderate or intensive in its use of database, then I will recomend to use a global connection.
You may want to take a look at the Database Application Block from the Microsoft Enterprise Library 3.0 (it's free -$0.00- !!!). It makes things a little bit easier to access the database and you don't have to control the connection state yourself (it handles the connection state, a connection pool, and so on):
http://msdn2.microsoft.com/en-us/library/aa480453.aspx
Hope this helps,
Carlos Camargo
"fniles" <fn****@pfmail.comescribió en el mensaje news:uF****************@TK2MSFTNGP06.phx.gbl...
>>Thank you. Does it mean that if I set MultipleActiveResultSets to true, I can have more than 1 DataReader open in the connection ?
Regarding using a local SQLConnection variable (instead of using a global one) and set it to new, open and close the connection everytime I fill a dataset, is it correct ? Or, do I need to use a global SQLConnection variable 1. new and open it on form_load (and do not close this one until form_Closed) 2. and in each subroutine use this global SQLConnection variable but new, open and close the connection in this subroutine ?
"Carlos Camargo" <cc******@INVALID.yahoo.comwrote in message news:um**************@TK2MSFTNGP06.phx.gbl... I get the same message a couple of weeks ago.
You can use the MultipleActiveResultSets on your connection string so you don't have to close a DataReader (or whatever) first to be able to go for the next one.
see this link with information about it: http://msdn2.microsoft.com/en-us/lib...esultsets.aspx
Hope it helps.
Best regards,
Carlos Camargo
"fniles" <fn****@pfmail.comescribió en el mensaje news:uy*************@TK2MSFTNGP05.phx.gbl... >I am using VB.NET 2003 and SQL 2005. To use connection pooling and avoid the error "There is already an open DataReader associated with this Connection which must be closed first." , I understand that I want to release/close connections in a timely fashion. What I do is I declare the SqlClient.SqlConnection variable as a local variable inside my subroutine (instead of a global variable). Right before I Fill the dataset I open the connection, and right after I fill the dataset I close the connection, like shown below. Do I do it correctly ? Thank you. > sub MySub Dim adoCon As SqlClient.SqlConnection Dim cmdSQL As SqlClient.SqlCommand Dim dsSQL As DataSet Dim daSQL As SqlClient.SqlDataAdapter > adoCon = New SqlClient.SqlConnection With adoCon .ConnectionString = DB_Path .Open() '--open connection End With cmdSQL = New SqlClient.SqlCommand With cmdSQL .Connection = adoCon .CommandText = sSQL End With daSQL = New SqlClient.SqlDataAdapter dsSQL = New DataSet daSQL.SelectCommand = m_cmdSQL daSQL.Fill(m_dsSQL) '--fill dataset If Not adoCon Is Nothing Then adoCon.Close() '--close connection adoCon = Nothing End If > > >
I am using VB.NET 2003, so MultipleActiveResultSets is not available (it's
available in 2005 according to another user here).
In the individual procedures if I do not open and close the connection, I
will get the error "There is already an open DataReader associated with this
Connection which must be closed first."
You mentioned that if I open and close the connection the application will
be slow, but I thought with connection pooling this won't be slow, am I
wrong ?
"Carlos Camargo" <cc******@INVALID.yahoo.comwrote in message
news:Oc**************@TK2MSFTNGP05.phx.gbl...
Open the connection in your application's entry point, for example in the
Load event for the main form, and store the resulting connection object in
a global variable.
Close it when that same form gets closed.
In individual procedures where you go for some info from the database or
update data there, just send the querys and get the results, don't open
the connection and close it again, because doing that (open and close
connections all the time) will make your application somehow slow because
opening the connection involves a relatively-heavy process for both, the
server computer and the client computer. Once a connection gets stablished
things will go faster.
Best regards,
Carlos Camargo
"fniles" <fn****@pfmail.comescribió en el mensaje
news:ew**************@TK2MSFTNGP03.phx.gbl...
>Thank you. If I use a global variable, does it mean that 1. I set it to new and open it on main form_load (and do not close this one until form_Closed) 2. and in each subroutine use this global SQLConnection variable but set it to new, open and close this connection in this subroutine ? or, simply in each subroutine use this global SQLConnection variable but set it to new, open and close this connection in this subroutine, and do not need to open it in the main form_load ?
"Carlos Camargo" <cc******@INVALID.yahoo.comwrote in message news:%2****************@TK2MSFTNGP03.phx.gbl...
>>Regarding MultipleActiveResultSets, that's right, set it to True and your may be able to have more than a DataReader open at the same time, just remember to close them anyway so the system behaves nicely with resources like memory usage, processor, network and so on.
Regarding the issue of using a local or global connection, it will depend on your application, but if the application is moderate or intensive in its use of database, then I will recomend to use a global connection.
You may want to take a look at the Database Application Block from the Microsoft Enterprise Library 3.0 (it's free -$0.00- !!!). It makes things a little bit easier to access the database and you don't have to control the connection state yourself (it handles the connection state, a connection pool, and so on):
http://msdn2.microsoft.com/en-us/library/aa480453.aspx
Hope this helps,
Carlos Camargo
"fniles" <fn****@pfmail.comescribió en el mensaje news:uF****************@TK2MSFTNGP06.phx.gbl.. . Thank you. Does it mean that if I set MultipleActiveResultSets to true, I can have more than 1 DataReader open in the connection ?
Regarding using a local SQLConnection variable (instead of using a global one) and set it to new, open and close the connection everytime I fill a dataset, is it correct ? Or, do I need to use a global SQLConnection variable 1. new and open it on form_load (and do not close this one until form_Closed) 2. and in each subroutine use this global SQLConnection variable but new, open and close the connection in this subroutine ?
"Carlos Camargo" <cc******@INVALID.yahoo.comwrote in message news:um**************@TK2MSFTNGP06.phx.gbl... >I get the same message a couple of weeks ago. > You can use the MultipleActiveResultSets on your connection string so you don't have to close a DataReader (or whatever) first to be able to go for the next one. > see this link with information about it: > > http://msdn2.microsoft.com/en-us/lib...esultsets.aspx > Hope it helps. > Best regards, > Carlos Camargo > "fniles" <fn****@pfmail.comescribió en el mensaje news:uy*************@TK2MSFTNGP05.phx.gbl... >>I am using VB.NET 2003 and SQL 2005. >To use connection pooling and avoid the error "There is already an >open DataReader associated with this Connection which must be closed >first." , I understand that I want to release/close connections in a >timely fashion. What I do is I declare the SqlClient.SqlConnection >variable as a local variable inside my subroutine (instead of a >global variable). Right before I Fill the dataset I open the >connection, and right after I fill the dataset I close the >connection, like shown below. Do I do it correctly ? Thank you. >> >sub MySub >Dim adoCon As SqlClient.SqlConnection >Dim cmdSQL As SqlClient.SqlCommand >Dim dsSQL As DataSet >Dim daSQL As SqlClient.SqlDataAdapter >> >adoCon = New SqlClient.SqlConnection >With adoCon > .ConnectionString = DB_Path > .Open() '--open connection >End With >cmdSQL = New SqlClient.SqlCommand >With cmdSQL > .Connection = adoCon > .CommandText = sSQL >End With >daSQL = New SqlClient.SqlDataAdapter >dsSQL = New DataSet >daSQL.SelectCommand = m_cmdSQL >daSQL.Fill(m_dsSQL) '--fill dataset >If Not adoCon Is Nothing Then >adoCon.Close() '--close connection >adoCon = Nothing >End If >> >> >> > >
Thanks Kerry,
For awhile there I thought that there was no rational people lurking on
this list.
I completely agree. Use MARS at your own risk. It is fraught with issues and
unintended side-effects. While it might mask the issue of an unclosed
operation on a connection, it simply delays the inevitable.
The ultimate solution to the problem is understanding how the
instantiation and tear-down of Connections works. You simply must close
connections when they are in scope--you can't depend on the finalizer or
garbage collector to do so.
--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker www.betav.com/blog/billva www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------
"Kerry Moorman" <Ke**********@discussions.microsoft.comwrote in message
news:A5**********************************@microsof t.com...
fniles,
MARS is a .Net 2 feature. You would need to use VS 2005 to have access to
it.
I will also mention that using MARS is more involved than just turning it
on
in the connection string. MARS has all sorts of ramifications that you
need
to understand really well before using it.
Kerry Moorman
"fniles" wrote:
>Also, when I set my connection string to the following Data Source=mySQL2005;Initial Catalog=myDB;User ID=myUserID;Password=myPass;MultipleActiveResultS ets=True I got the error "Keyword not supported: 'multipleactiveresultsets'.
Dim adoCon As SqlClient.SqlConnection With adoCon .ConnectionString = DB_Path -->>error here .Open() End With "Carlos Camargo" <cc******@INVALID.yahoo.comwrote in message news:um**************@TK2MSFTNGP06.phx.gbl...
>I get the same message a couple of weeks ago.
You can use the MultipleActiveResultSets on your connection string so
you
don't have to close a DataReader (or whatever) first to be able to go
for
the next one.
see this link with information about it: http://msdn2.microsoft.com/en-us/lib...esultsets.aspx
Hope it helps.
Best regards,
Carlos Camargo
"fniles" <fn****@pfmail.comescribió en el mensaje
news:uy*************@TK2MSFTNGP05.phx.gbl... I am using VB.NET 2003 and SQL 2005. To use connection pooling and avoid the error "There is already an open DataReader associated with this Connection which must be closed first." , I understand that I want to release/close connections in a timely fashion. What I do is I declare the SqlClient.SqlConnection variable as a local variable inside my subroutine (instead of a global variable). Right before I Fill the dataset I open the connection, and right after I fill the dataset I close the connection, like shown below. Do I do it correctly ? Thank you.
sub MySub Dim adoCon As SqlClient.SqlConnection Dim cmdSQL As SqlClient.SqlCommand Dim dsSQL As DataSet Dim daSQL As SqlClient.SqlDataAdapter
adoCon = New SqlClient.SqlConnection With adoCon .ConnectionString = DB_Path .Open() '--open connection End With cmdSQL = New SqlClient.SqlCommand With cmdSQL .Connection = adoCon .CommandText = sSQL End With daSQL = New SqlClient.SqlDataAdapter dsSQL = New DataSet daSQL.SelectCommand = m_cmdSQL daSQL.Fill(m_dsSQL) '--fill dataset If Not adoCon Is Nothing Then adoCon.Close() '--close connection adoCon = Nothing End If
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Florin |
last post by:
Hi,
I am experiencing some problems accessing an Oracle database through
OLE DB from an MTS application using OpenWithServiceComponents (which
is supposed to give me connection pooling).
When I...
|
by: rob |
last post by:
Hello,
Newbie of sorts. Been reading up on best practices though.
I'm trying to optimize performance to the SQL DB vs. the Web server and
an ASP application. I've read that you're supposed to...
|
by: Mark |
last post by:
Where is the connection pooling done when using ADO.NET and SQL Server? On
the SQL Server or where the .NET run-time is being executed? I'm assuming
on SQL Server as this would minimize the...
|
by: Vb2Machines |
last post by:
Hello,
I am in the process of building a web service that will connect to my sql
server for data retrieval only. It will have to handle requests from multiple
apps on our shop floor. Roughly 5...
|
by: John J. Hughes II |
last post by:
I have an application that connects to an SQL server. I need to be able to
disconnect all connection that I opened. I am closing and disposing the
connection but the connection pool is keeping...
| |
by: Lenny Shprekher |
last post by:
Hi,
I am getting issues that Oracle collecting opened sessions (connections)
from my webservice using regular System.Data.OleDb.OleDbConnection object.
I am guessing that this is connection...
|
by: Mrinal Kamboj |
last post by:
Hi ,
I am using OracleConnection object from Oracle ODP.net provider and
following is the behaviour which i am finding bit strange :
To start with my argument is based on followings facts :
...
|
by: viswarajan |
last post by:
Introduction
This article is to go in deep in dome key features in the ADO.NET 2 which was shipped with VS 2005.
In this article I will go trough one of the key features which is the Connection...
|
by: =?Utf-8?B?QXho?= |
last post by:
Is there a limitation on the number of (sequential) opened connection for SQL
Server User Instances? The following method will run to about the 240th
iteration then will receive a timeout...
|
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: 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...
| |
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,...
|
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...
|
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...
|
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...
|
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...
|
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 ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |