Connection pooling question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Cor Ligthert [MVP]

    #16
    Re: Connection pooling question

    Fniles,

    Why not buy the book from Bill, it does not help you much in a high
    theoretical question without answer.

    However for those practical questions that you have now it is very good.

    (I had it on my desk Bill, however my collegues took it away)

    Cor

    "fniles" <fniles@pfmail. comschreef in bericht
    news:e$oWnVcgHH A.596@TK2MSFTNG P05.phx.gbl...
    Also, 1 more question.
    The way I do connection pooling is the following:
    In the main form load I open a connection using a connection string that I
    stored in a global variable g_sConnectionSt ring and leave this connection
    open and not close it until it exits the application.
    Then on each thread I create a local OleDBConnection variable, open the
    connection using the exact same connection string as the main form (stored
    in global variable g_sConnectionSt ring), and close it after populating a
    DataSet.
    Is this correct ?
    >
    Thank you.
    >
    "William (Bill) Vaughn" <billva@NoSpamA tAll_betav.comw rote in message
    news:ulZ4z6UgHH A.1388@TK2MSFTN GP05.phx.gbl...
    >CP::Connecti on Pool
    >The differences between JET and SQL Server are ... well, dramatic. They
    >are designed very differently. JET is a throw-back to shared-file ISAM
    >(dBASE) database engines (circa 1970's) while SQL Server is a
    >service-based engine designed to handle many, many users and far more
    >secure and scalable database requirements. I characterize JET as a "home"
    >database and I don't recommend it for any (serious) business
    >applications--despite the fact that it's in very wide use all over the
    >world in lots of businesses. It makes a sad web DBMS engine. While it can
    >work, you're likely to see more and more serious (unsolvable) problems
    >with JET when used incorrectly.
    >>
    >Will SQL Server tolerate code that does not properly close connections?
    >Nope, its connection pool will overflow if you don't write the
    >application correctly. Will it expose more counters and trace metrics to
    >let you inspect the CP status? Sure and then some. Is it designed for use
    >in a web site? Absolutely.
    >>
    >I looked at your code (again) and I see that you're manually opening the
    >connection. You don't have to. In your case I suggest that you don't. The
    >Fill method opens the connection (if it's not already open), runs the
    >query, populates the DataSet and closes the connection (if it was opened
    >by Fill).
    >>
    >I still suspect you might be over-running the ability of JET to handle
    >the workload. Remember JET can't stop work on a query and service another
    >request. All requests are handled serially (unlike SQL Server).
    >>
    >I discuss all of this and more in my latest book.
    >>
    >--
    >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
    >books:
    >Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition) and
    >Hitchhiker's Guide to SQL Server 2005 Compact Edition
    >>
    >-----------------------------------------------------------------------------------------------------------------------
    >"fniles" <fniles@pfmail. comwrote in message
    >news:ego1grRgH HA.3960@TK2MSFT NGP02.phx.gbl.. .
    >>Thank you.
    >>>>If the cause of your problem is the CP
    >>What did you mean by CP ?
    >>>
    >>>>JET is not designed for this kind of work.
    >>So, if I use SQL Server (and assuming I use the code like below, except
    >>using SqlConnection instead of OLEDbConnection ), most likely I will not
    >>have the problem where the pool is filling like in Access ? Is the
    >>maximum pool size in Access smaller than in SQL Server (where the
    >>default is 100) ?
    >>>
    >>I close the connection right after I fill the dataset like shown below.
    >>Can I close the connection faster then the way I do it ?
    >>This code is called everytime somebody login to the application.
    >>>
    >>Dim cmd As New OleDb.OleDbComm and
    >>Dim da As OleDb.OleDbData Adapter
    >>Dim ds As DataSet
    >>Dim ConnectionDemoO LE As OleDb.OleDbConn ection
    >>With cmd
    >> bDBSuccess = OpenDBDemoOLE(C onnectionDemoOL E)
    >> If bDBSuccess Then
    >> .Connection = ConnectionDemoO LE
    >> .CommandText = sql
    >> Try
    >> da = New OleDb.OleDbData Adapter
    >> ds = New DataSet
    >> da.SelectComman d = cmd
    >> da.Fill(ds)
    >> CloseConDemoOLE (ConnectionDemo OLE)
    >> Catch ex As Exception
    >> end try
    >> Sub CloseConDemoOLE (ByRef ConnectionDemoO LE As OleDb.OleDbConn ection)
    >> If Not ConnectionDemoO LE Is Nothing Then
    >> ConnectionDemoO LE.Close()
    >> ConnectionDemoO LE = Nothing
    >> End If
    >> End Sub
    >>>
    >> Function OpenDBDemoOLE(B yRef ConnectionDemoO LE As
    >>OleDb.OleDbCo nnection) As Boolean
    >> Try
    >> ConnectionDemoO LE = New OleDb.OleDbConn ection
    >> OpenDBDemoOLE = True
    >> With ConnectionDemoO LE
    >> .ConnectionStri ng = g_dbPathDemo
    >> .Open()
    >> If .State = ConnectionState .Closed Then
    >> CloseConDemoOLE (ConnectionDemo OLE)
    >> OpenDBDemoOLE = False
    >> End If
    >> End With
    >> Catch ex As Exception
    >>end try
    >>>
    >>"William (Bill) Vaughn" <billva@NoSpamA tAll_betav.comw rote in message
    >>news:Oroa83Qg HHA.3460@TK2MSF TNGP04.phx.gbl. ..
    >>>Ah, I doubt if this will help. It assumes that the engine has enough
    >>>idle time to do it's work. The fundamental issue is clear. If the cause
    >>>of your problem is the CP and the pool is filling then something is
    >>>overloadin g the engine or your code is not releasing/closing
    >>>connection s in a timely fashion. Again, JET is not designed for this
    >>>kind of work. I think you're beating a dead horse.
    >>>>
    >>>--
    >>>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
    >>>books:
    >>>Hitchhiker 's Guide to Visual Studio and SQL Server (7th Edition) and
    >>>Hitchhiker 's Guide to SQL Server 2005 Compact Edition
    >>>>
    >>>-----------------------------------------------------------------------------------------------------------------------
    >>>"fniles" <fniles@pfmail. comwrote in message
    >>>news:OUmc0jK gHHA.2640@TK2MS FTNGP06.phx.gbl ...
    >>>>Thank you.
    >>>>I do use try/catch, but I get the "Unspecifie d error".
    >>>>>
    >>>>When the maximum pool size has been reached and I get an error, how
    >>>>can I loop and wait until a connection is available again ?
    >>>>>
    >>>> Try
    >>>> ConnectionOLE = New OleDb.OleDbConn ection
    >>>> OpenDBOLE = True
    >>>> With ConnectionOLE
    >>>> .ConnectionStri ng = g_dbPath
    >>>> .Open() --IF MAX POOL SIZE HAS BEEN REACHED, IT WILL
    >>>>GO to the Catch. How can I loop and wait to open the db until a
    >>>>connectio n is available again ?
    >>>> End With
    >>>> Catch ex As Exception
    >>>> Try
    >>>>>
    >>>>Thank you.
    >>>>>
    >>>>"William (Bill) Vaughn" <billva@NoSpamA tAll_betav.comw rote in
    >>>>message news:OlI3%236Hg HHA.4804@TK2MSF TNGP02.phx.gbl. ..
    >>>>>See >>>>>
    >>>>>>
    >>>>>--
    >>>>>William (Bill) Vaughn
    >>>>>Author, Mentor, Consultant
    >>>>>Microsof t 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
    >>>>>books:
    >>>>>Hitchhiker 's Guide to Visual Studio and SQL Server (7th Edition) and
    >>>>>Hitchhiker 's Guide to SQL Server 2005 Compact Edition
    >>>>>>
    >>>>>-----------------------------------------------------------------------------------------------------------------------
    >>>>>"fniles" <fniles@pfmail. comwrote in message
    >>>>>news:%23uA CzGHgHHA.4260@T K2MSFTNGP03.phx .gbl...
    >>>>>>>I am using VB.Net 2003 over a LAN, and I have no choice but to use MS
    >>>>>>>Access .
    >>>>>>In SQL Server, in the connection string you can set the max pool
    >>>>>>size, can you do that in MS Access ?
    >>>>>>
    >>>>>>>>>>Nop e.
    >>>>>>
    >>>>>>>
    >>>>>>You mentioned that "If you exhaust the pool you should get a timeout
    >>>>>>exception ." So, you will get an error, right ?
    >>>>>>I mean if you put try-catch-end try, it will go to the Cath section,
    >>>>>>right ?
    >>>>>>
    >>>>>>>>>>Right .
    >>>>>>
    >>>>>>In my other posting I posted that sometimes I get "Unspecifie d
    >>>>>>error" on the Open method when opening up the OleDBConnection . This
    >>>>>>does not happen all the time, only sometimes, which makes me think
    >>>>>>that maybe the maximum pool size has been reached ? Is it possible
    >>>>>>that the "Unspecifie d error" on the Open method caused by the
    >>>>>>maximum pool size has been reached ?
    >>>>>>
    >>>>>>>>>"Unspe cified" errors generally means you don't have a Try/Catch
    >>>>>>>>>bloc k to trap the specific exception. In Access/JET, yes it might
    >>>>>>>>>mean the pool is full or the database is corrupt, or almost
    >>>>>>>>>anythi ng else.
    >>>>>>
    >>>>>>
    >>>>>>>
    >>>>>> Dim swError As StreamWriter
    >>>>>> Dim sSub As String
    >>>>>> Try
    >>>>>> sSub = "1"
    >>>>>> ConnectionOLE = New OleDb.OleDbConn ection
    >>>>>> OpenDBOLE = True
    >>>>>> With ConnectionOLE
    >>>>>> .ConnectionStri ng = g_dbPath
    >>>>>> sSub = "2"
    >>>>>> .Open() --IF MAX POOL SIZE HAS BEEN REACHED, IT
    >>>>>>WILL GO TO THE Catch section below ?
    >>>>>>
    >>>>>>>>In theory... yes.
    >>>>>>
    >>>>>>
    >>>>>> sSub = "3"
    >>>>>> End With
    >>>>>> Catch ex As Exception
    >>>>>> swError = New StreamWriter(Ap plication.Start upPath &
    >>>>>>"\AQError Log" & Date.Now.ToStri ng("MMddyy") & ".txt", True)
    >>>>>> swError.Write(N ow & " OpenDBOLE - error = " &
    >>>>>>ex.Messag e & " sub = " & sSub & " g_dbPath = " & g_dbPath & vbCrLf)
    >>>>>> swError.Close()
    >>>>>> swError = Nothing
    >>>>>> End Try
    >>>>>>>
    >>>>>>Thank you.
    >>>>>>>
    >>>>>>>
    >>>>>>>
    >>>>>>"Willia m (Bill) Vaughn" <billva@NoSpamA tAll_betav.comw rote in
    >>>>>>message news:u2%23Nf5Gg HHA.3388@TK2MSF TNGP02.phx.gbl. ..
    >>>>>>>>I don't think there are any system counters exposed by the JET
    >>>>>>>>provide r or by OLE DB to monitor the CP.
    >>>>>>>If you exhaust the pool you should get a timeout exception.
    >>>>>>>Howeve r, (and Ginny please correct me here), if you're working with
    >>>>>>>JET and an ASP application, you've got your wires crossed. JET is
    >>>>>>>not designed to provide data for more than one user. Sure, you can
    >>>>>>>share a JET .MDB database over a LAN, but each user gets its own
    >>>>>>>JET engine to access the file. Using it in a web application that
    >>>>>>>requir es one JET engine to access the data is problematic at best.
    >>>>>>>I suggest using a DBMS designed for the web--SQL Express.
    >>>>>>>>
    >>>>>>>hth
    >>>>>>>>
    >>>>>>>--
    >>>>>>>Willia m (Bill) Vaughn
    >>>>>>>Author , Mentor, Consultant
    >>>>>>>Microsof t 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
    >>>>>>>books:
    >>>>>>>Hitchhik er's Guide to Visual Studio and SQL Server (7th Edition)
    >>>>>>>and
    >>>>>>>Hitchhik er's Guide to SQL Server 2005 Compact Edition
    >>>>>>>>
    >>>>>>>-----------------------------------------------------------------------------------------------------------------------
    >>>>>>>"fnile s" <fniles@pfmail. comwrote in message
    >>>>>>>news:ejD HZzGgHHA.4368@T K2MSFTNGP03.phx .gbl...
    >>>>>>>>>I am using VS2003 and connecting to MS Access database.
    >>>>>>>>When using a connection pooling (every time I open the
    >>>>>>>>OLEDBCO NNECTION I use the exact matching connection string),
    >>>>>>>>1. how can I know how many connection has been used ?
    >>>>>>>>2. If the maximum pool size has been reached, what happens when I
    >>>>>>>>call the method Open to open the connection ? Will I get an error
    >>>>>>>>? MSDN says the request is queued, but will I get an error in the
    >>>>>>>>open method ?
    >>>>>>>>>
    >>>>>>>>Connect ionDemoOLE = New OleDb.OleDbConn ection
    >>>>>>>>sPath = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" & sDBPath
    >>>>>>>>& ";OLE DB
    >>>>>>>>Service s=-1"
    >>>>>>>>With ConnectionDemoO LE
    >>>>>>>> .ConnectionStri ng = sPath
    >>>>>>>> .Open() --what happens here when the maximum pool size has
    >>>>>>>>been reached ?
    >>>>>>>>>
    >>>>>>>>Thank s
    >>>>>>>>>
    >>>>>>>>>
    >>>>>>>>
    >>>>>>>>
    >>>>>>>
    >>>>>>>
    >>>>>>
    >>>>>>
    >>>>>
    >>>>>
    >>>>
    >>>>
    >>>
    >>>
    >>
    >>
    >
    >

    Comment

    • William \(Bill\) Vaughn

      #17
      Re: Connection pooling question

      Instantiating a Connection object and opening the connection to the data
      source are two different steps.
      You can create a global Connection object that's visible to the entire
      application. In some situations this makes sense--especially in Windows
      Forms applications.
      Opening the connection changes the State, links the application to the data
      source (like opening a file), and permits the application to send queries to
      the data source (like a DBMS engine).

      Each application gets its own pool. Two applications running on the same
      machine in different process spaces get their own pool--even if the
      ConnectionStrin g is the same.


      --
      William (Bill) Vaughn
      Author, Mentor, Consultant
      Microsoft MVP
      INETA Speaker
      Welcome to the home of William Vaughn's Imagination, creations, and advice.

      Welcome to the home of William Vaughn's Imagination, creations, and advice.

      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 books:
      Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition) and
      Hitchhiker's Guide to SQL Server 2005 Compact Edition

      -----------------------------------------------------------------------------------------------------------------------
      "fniles" <fniles@pfmail. comwrote in message
      news:%23zXJj4bg HHA.2400@TK2MSF TNGP04.phx.gbl. ..
      Thank you one more time. You are very helpful.
      You suggested to not open the connection manually. How do you do that ?
      Don't I need to assign a connection to the OleDbCommand ?
      You mentioned the Fill method opens the connection, how does it know what
      connection ?
      >
      Will my code than look something like below :
      >
      Dim cmd As New OleDb.OleDbComm and
      Dim da As OleDb.OleDbData Adapter
      Dim ds As DataSet
      Dim ConnectionDemoO LE As OleDb.OleDbConn ection
      With cmd
      '----DO NOT NEED THIS CODE ----- bDBSuccess =
      OpenDBDemoOLE(C onnectionDemoOL E) ------'
      '----If bDBSuccess Then
      .Connection = ConnectionDemoO LE '????
      .CommandText = sql
      Try
      da = New OleDb.OleDbData Adapter
      ds = New DataSet
      da.SelectComman d = cmd
      da.Fill(ds)
      CloseConDemoOLE (ConnectionDemo OLE)
      Catch ex As Exception
      end try
      >
      Thank you.
      >
      "William (Bill) Vaughn" <billva@NoSpamA tAll_betav.comw rote in message
      news:ulZ4z6UgHH A.1388@TK2MSFTN GP05.phx.gbl...
      >CP::Connecti on Pool
      >The differences between JET and SQL Server are ... well, dramatic. They
      >are designed very differently. JET is a throw-back to shared-file ISAM
      >(dBASE) database engines (circa 1970's) while SQL Server is a
      >service-based engine designed to handle many, many users and far more
      >secure and scalable database requirements. I characterize JET as a "home"
      >database and I don't recommend it for any (serious) business
      >applications--despite the fact that it's in very wide use all over the
      >world in lots of businesses. It makes a sad web DBMS engine. While it can
      >work, you're likely to see more and more serious (unsolvable) problems
      >with JET when used incorrectly.
      >>
      >Will SQL Server tolerate code that does not properly close connections?
      >Nope, its connection pool will overflow if you don't write the
      >application correctly. Will it expose more counters and trace metrics to
      >let you inspect the CP status? Sure and then some. Is it designed for use
      >in a web site? Absolutely.
      >>
      >I looked at your code (again) and I see that you're manually opening the
      >connection. You don't have to. In your case I suggest that you don't. The
      >Fill method opens the connection (if it's not already open), runs the
      >query, populates the DataSet and closes the connection (if it was opened
      >by Fill).
      >>
      >I still suspect you might be over-running the ability of JET to handle
      >the workload. Remember JET can't stop work on a query and service another
      >request. All requests are handled serially (unlike SQL Server).
      >>
      >I discuss all of this and more in my latest book.
      >>
      >--
      >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
      >books:
      >Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition) and
      >Hitchhiker's Guide to SQL Server 2005 Compact Edition
      >>
      >-----------------------------------------------------------------------------------------------------------------------
      >"fniles" <fniles@pfmail. comwrote in message
      >news:ego1grRgH HA.3960@TK2MSFT NGP02.phx.gbl.. .
      >>Thank you.
      >>>>If the cause of your problem is the CP
      >>What did you mean by CP ?
      >>>
      >>>>JET is not designed for this kind of work.
      >>So, if I use SQL Server (and assuming I use the code like below, except
      >>using SqlConnection instead of OLEDbConnection ), most likely I will not
      >>have the problem where the pool is filling like in Access ? Is the
      >>maximum pool size in Access smaller than in SQL Server (where the
      >>default is 100) ?
      >>>
      >>I close the connection right after I fill the dataset like shown below.
      >>Can I close the connection faster then the way I do it ?
      >>This code is called everytime somebody login to the application.
      >>>
      >>Dim cmd As New OleDb.OleDbComm and
      >>Dim da As OleDb.OleDbData Adapter
      >>Dim ds As DataSet
      >>Dim ConnectionDemoO LE As OleDb.OleDbConn ection
      >>With cmd
      >> bDBSuccess = OpenDBDemoOLE(C onnectionDemoOL E)
      >> If bDBSuccess Then
      >> .Connection = ConnectionDemoO LE
      >> .CommandText = sql
      >> Try
      >> da = New OleDb.OleDbData Adapter
      >> ds = New DataSet
      >> da.SelectComman d = cmd
      >> da.Fill(ds)
      >> CloseConDemoOLE (ConnectionDemo OLE)
      >> Catch ex As Exception
      >> end try
      >> Sub CloseConDemoOLE (ByRef ConnectionDemoO LE As OleDb.OleDbConn ection)
      >> If Not ConnectionDemoO LE Is Nothing Then
      >> ConnectionDemoO LE.Close()
      >> ConnectionDemoO LE = Nothing
      >> End If
      >> End Sub
      >>>
      >> Function OpenDBDemoOLE(B yRef ConnectionDemoO LE As
      >>OleDb.OleDbCo nnection) As Boolean
      >> Try
      >> ConnectionDemoO LE = New OleDb.OleDbConn ection
      >> OpenDBDemoOLE = True
      >> With ConnectionDemoO LE
      >> .ConnectionStri ng = g_dbPathDemo
      >> .Open()
      >> If .State = ConnectionState .Closed Then
      >> CloseConDemoOLE (ConnectionDemo OLE)
      >> OpenDBDemoOLE = False
      >> End If
      >> End With
      >> Catch ex As Exception
      >>end try
      >>>
      >>"William (Bill) Vaughn" <billva@NoSpamA tAll_betav.comw rote in message
      >>news:Oroa83Qg HHA.3460@TK2MSF TNGP04.phx.gbl. ..
      >>>Ah, I doubt if this will help. It assumes that the engine has enough
      >>>idle time to do it's work. The fundamental issue is clear. If the cause
      >>>of your problem is the CP and the pool is filling then something is
      >>>overloadin g the engine or your code is not releasing/closing
      >>>connection s in a timely fashion. Again, JET is not designed for this
      >>>kind of work. I think you're beating a dead horse.
      >>>>
      >>>--
      >>>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
      >>>books:
      >>>Hitchhiker 's Guide to Visual Studio and SQL Server (7th Edition) and
      >>>Hitchhiker 's Guide to SQL Server 2005 Compact Edition
      >>>>
      >>>-----------------------------------------------------------------------------------------------------------------------
      >>>"fniles" <fniles@pfmail. comwrote in message
      >>>news:OUmc0jK gHHA.2640@TK2MS FTNGP06.phx.gbl ...
      >>>>Thank you.
      >>>>I do use try/catch, but I get the "Unspecifie d error".
      >>>>>
      >>>>When the maximum pool size has been reached and I get an error, how
      >>>>can I loop and wait until a connection is available again ?
      >>>>>
      >>>> Try
      >>>> ConnectionOLE = New OleDb.OleDbConn ection
      >>>> OpenDBOLE = True
      >>>> With ConnectionOLE
      >>>> .ConnectionStri ng = g_dbPath
      >>>> .Open() --IF MAX POOL SIZE HAS BEEN REACHED, IT WILL
      >>>>GO to the Catch. How can I loop and wait to open the db until a
      >>>>connectio n is available again ?
      >>>> End With
      >>>> Catch ex As Exception
      >>>> Try
      >>>>>
      >>>>Thank you.
      >>>>>
      >>>>"William (Bill) Vaughn" <billva@NoSpamA tAll_betav.comw rote in
      >>>>message news:OlI3%236Hg HHA.4804@TK2MSF TNGP02.phx.gbl. ..
      >>>>>See >>>>>
      >>>>>>
      >>>>>--
      >>>>>William (Bill) Vaughn
      >>>>>Author, Mentor, Consultant
      >>>>>Microsof t 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
      >>>>>books:
      >>>>>Hitchhiker 's Guide to Visual Studio and SQL Server (7th Edition) and
      >>>>>Hitchhiker 's Guide to SQL Server 2005 Compact Edition
      >>>>>>
      >>>>>-----------------------------------------------------------------------------------------------------------------------
      >>>>>"fniles" <fniles@pfmail. comwrote in message
      >>>>>news:%23uA CzGHgHHA.4260@T K2MSFTNGP03.phx .gbl...
      >>>>>>>I am using VB.Net 2003 over a LAN, and I have no choice but to use MS
      >>>>>>>Access .
      >>>>>>In SQL Server, in the connection string you can set the max pool
      >>>>>>size, can you do that in MS Access ?
      >>>>>>
      >>>>>>>>>>Nop e.
      >>>>>>
      >>>>>>>
      >>>>>>You mentioned that "If you exhaust the pool you should get a timeout
      >>>>>>exception ." So, you will get an error, right ?
      >>>>>>I mean if you put try-catch-end try, it will go to the Cath section,
      >>>>>>right ?
      >>>>>>
      >>>>>>>>>>Right .
      >>>>>>
      >>>>>>In my other posting I posted that sometimes I get "Unspecifie d
      >>>>>>error" on the Open method when opening up the OleDBConnection . This
      >>>>>>does not happen all the time, only sometimes, which makes me think
      >>>>>>that maybe the maximum pool size has been reached ? Is it possible
      >>>>>>that the "Unspecifie d error" on the Open method caused by the
      >>>>>>maximum pool size has been reached ?
      >>>>>>
      >>>>>>>>>"Unspe cified" errors generally means you don't have a Try/Catch
      >>>>>>>>>bloc k to trap the specific exception. In Access/JET, yes it might
      >>>>>>>>>mean the pool is full or the database is corrupt, or almost
      >>>>>>>>>anythi ng else.
      >>>>>>
      >>>>>>
      >>>>>>>
      >>>>>> Dim swError As StreamWriter
      >>>>>> Dim sSub As String
      >>>>>> Try
      >>>>>> sSub = "1"
      >>>>>> ConnectionOLE = New OleDb.OleDbConn ection
      >>>>>> OpenDBOLE = True
      >>>>>> With ConnectionOLE
      >>>>>> .ConnectionStri ng = g_dbPath
      >>>>>> sSub = "2"
      >>>>>> .Open() --IF MAX POOL SIZE HAS BEEN REACHED, IT
      >>>>>>WILL GO TO THE Catch section below ?
      >>>>>>
      >>>>>>>>In theory... yes.
      >>>>>>
      >>>>>>
      >>>>>> sSub = "3"
      >>>>>> End With
      >>>>>> Catch ex As Exception
      >>>>>> swError = New StreamWriter(Ap plication.Start upPath &
      >>>>>>"\AQError Log" & Date.Now.ToStri ng("MMddyy") & ".txt", True)
      >>>>>> swError.Write(N ow & " OpenDBOLE - error = " &
      >>>>>>ex.Messag e & " sub = " & sSub & " g_dbPath = " & g_dbPath & vbCrLf)
      >>>>>> swError.Close()
      >>>>>> swError = Nothing
      >>>>>> End Try
      >>>>>>>
      >>>>>>Thank you.
      >>>>>>>
      >>>>>>>
      >>>>>>>
      >>>>>>"Willia m (Bill) Vaughn" <billva@NoSpamA tAll_betav.comw rote in
      >>>>>>message news:u2%23Nf5Gg HHA.3388@TK2MSF TNGP02.phx.gbl. ..
      >>>>>>>>I don't think there are any system counters exposed by the JET
      >>>>>>>>provide r or by OLE DB to monitor the CP.
      >>>>>>>If you exhaust the pool you should get a timeout exception.
      >>>>>>>Howeve r, (and Ginny please correct me here), if you're working with
      >>>>>>>JET and an ASP application, you've got your wires crossed. JET is
      >>>>>>>not designed to provide data for more than one user. Sure, you can
      >>>>>>>share a JET .MDB database over a LAN, but each user gets its own
      >>>>>>>JET engine to access the file. Using it in a web application that
      >>>>>>>requir es one JET engine to access the data is problematic at best.
      >>>>>>>I suggest using a DBMS designed for the web--SQL Express.
      >>>>>>>>
      >>>>>>>hth
      >>>>>>>>
      >>>>>>>--
      >>>>>>>Willia m (Bill) Vaughn
      >>>>>>>Author , Mentor, Consultant
      >>>>>>>Microsof t 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
      >>>>>>>books:
      >>>>>>>Hitchhik er's Guide to Visual Studio and SQL Server (7th Edition)
      >>>>>>>and
      >>>>>>>Hitchhik er's Guide to SQL Server 2005 Compact Edition
      >>>>>>>>
      >>>>>>>-----------------------------------------------------------------------------------------------------------------------
      >>>>>>>"fnile s" <fniles@pfmail. comwrote in message
      >>>>>>>news:ejD HZzGgHHA.4368@T K2MSFTNGP03.phx .gbl...
      >>>>>>>>>I am using VS2003 and connecting to MS Access database.
      >>>>>>>>When using a connection pooling (every time I open the
      >>>>>>>>OLEDBCO NNECTION I use the exact matching connection string),
      >>>>>>>>1. how can I know how many connection has been used ?
      >>>>>>>>2. If the maximum pool size has been reached, what happens when I
      >>>>>>>>call the method Open to open the connection ? Will I get an error
      >>>>>>>>? MSDN says the request is queued, but will I get an error in the
      >>>>>>>>open method ?
      >>>>>>>>>
      >>>>>>>>Connect ionDemoOLE = New OleDb.OleDbConn ection
      >>>>>>>>sPath = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" & sDBPath
      >>>>>>>>& ";OLE DB
      >>>>>>>>Service s=-1"
      >>>>>>>>With ConnectionDemoO LE
      >>>>>>>> .ConnectionStri ng = sPath
      >>>>>>>> .Open() --what happens here when the maximum pool size has
      >>>>>>>>been reached ?
      >>>>>>>>>
      >>>>>>>>Thank s
      >>>>>>>>>
      >>>>>>>>>
      >>>>>>>>
      >>>>>>>>
      >>>>>>>
      >>>>>>>
      >>>>>>
      >>>>>>
      >>>>>
      >>>>>
      >>>>
      >>>>
      >>>
      >>>
      >>
      >>
      >
      >

      Comment

      • fniles

        #18
        Re: Connection pooling question

        Thank you.
        I am sorry I am still not clear on how to call the Fill method without
        opening the connection manually before hand.
        Do you have to open the connection sometime before hand ?
        Each application gets its own pool. Two applications running on the same
        machine in different process spaces get their own pool--even if the
        ConnectionStrin g is the same.
        If for example application A and B uses the same database (either Access or
        SQL Server). If maximum connection pooling is 100, each application will get
        100 maximum connection pooling, is this correct ?

        I notice when the application uses an Access db on my machine (where no
        other application access that database) my application does not reach the
        maximum pool connection as fast as when I use an Access db on our server
        (where many other applications access that database).
        Is this because even though my application say has maximum of 100
        connections, because other applications access the same database, there may
        not be connection available ?

        "William (Bill) Vaughn" <billva@NoSpamA tAll_betav.comw rote in message
        news:%23B715Ieg HHA.1220@TK2MSF TNGP03.phx.gbl. ..
        Instantiating a Connection object and opening the connection to the data
        source are two different steps.
        You can create a global Connection object that's visible to the entire
        application. In some situations this makes sense--especially in Windows
        Forms applications.
        Opening the connection changes the State, links the application to the
        data source (like opening a file), and permits the application to send
        queries to the data source (like a DBMS engine).
        >
        Each application gets its own pool. Two applications running on the same
        machine in different process spaces get their own pool--even if the
        ConnectionStrin g is the same.
        >
        >
        --
        William (Bill) Vaughn
        Author, Mentor, Consultant
        Microsoft MVP
        INETA Speaker
        Welcome to the home of William Vaughn's Imagination, creations, and advice.

        Welcome to the home of William Vaughn's Imagination, creations, and advice.

        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 books:
        Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition) and
        Hitchhiker's Guide to SQL Server 2005 Compact Edition
        >
        -----------------------------------------------------------------------------------------------------------------------
        "fniles" <fniles@pfmail. comwrote in message
        news:%23zXJj4bg HHA.2400@TK2MSF TNGP04.phx.gbl. ..
        >Thank you one more time. You are very helpful.
        >You suggested to not open the connection manually. How do you do that ?
        >Don't I need to assign a connection to the OleDbCommand ?
        >You mentioned the Fill method opens the connection, how does it know what
        >connection ?
        >>
        >Will my code than look something like below :
        >>
        >Dim cmd As New OleDb.OleDbComm and
        >Dim da As OleDb.OleDbData Adapter
        >Dim ds As DataSet
        >Dim ConnectionDemoO LE As OleDb.OleDbConn ection
        >With cmd
        > '----DO NOT NEED THIS CODE ----- bDBSuccess =
        >OpenDBDemoOLE( ConnectionDemoO LE) ------'
        > '----If bDBSuccess Then
        > .Connection = ConnectionDemoO LE '????
        > .CommandText = sql
        > Try
        > da = New OleDb.OleDbData Adapter
        > ds = New DataSet
        > da.SelectComman d = cmd
        > da.Fill(ds)
        > CloseConDemoOLE (ConnectionDemo OLE)
        > Catch ex As Exception
        > end try
        >>
        >Thank you.
        >>
        >"William (Bill) Vaughn" <billva@NoSpamA tAll_betav.comw rote in message
        >news:ulZ4z6UgH HA.1388@TK2MSFT NGP05.phx.gbl.. .
        >>CP::Connectio n Pool
        >>The differences between JET and SQL Server are ... well, dramatic. They
        >>are designed very differently. JET is a throw-back to shared-file ISAM
        >>(dBASE) database engines (circa 1970's) while SQL Server is a
        >>service-based engine designed to handle many, many users and far more
        >>secure and scalable database requirements. I characterize JET as a
        >>"home" database and I don't recommend it for any (serious) business
        >>application s--despite the fact that it's in very wide use all over the
        >>world in lots of businesses. It makes a sad web DBMS engine. While it
        >>can work, you're likely to see more and more serious (unsolvable)
        >>problems with JET when used incorrectly.
        >>>
        >>Will SQL Server tolerate code that does not properly close connections?
        >>Nope, its connection pool will overflow if you don't write the
        >>application correctly. Will it expose more counters and trace metrics to
        >>let you inspect the CP status? Sure and then some. Is it designed for
        >>use in a web site? Absolutely.
        >>>
        >>I looked at your code (again) and I see that you're manually opening the
        >>connection. You don't have to. In your case I suggest that you don't.
        >>The Fill method opens the connection (if it's not already open), runs
        >>the query, populates the DataSet and closes the connection (if it was
        >>opened by Fill).
        >>>
        >>I still suspect you might be over-running the ability of JET to handle
        >>the workload. Remember JET can't stop work on a query and service
        >>another request. All requests are handled serially (unlike SQL Server).
        >>>
        >>I discuss all of this and more in my latest book.
        >>>
        >>--
        >>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
        >>books:
        >>Hitchhiker' s Guide to Visual Studio and SQL Server (7th Edition) and
        >>Hitchhiker' s Guide to SQL Server 2005 Compact Edition
        >>>
        >>-----------------------------------------------------------------------------------------------------------------------
        >>"fniles" <fniles@pfmail. comwrote in message
        >>news:ego1grRg HHA.3960@TK2MSF TNGP02.phx.gbl. ..
        >>>Thank you.
        >>>>>If the cause of your problem is the CP
        >>>What did you mean by CP ?
        >>>>
        >>>>>JET is not designed for this kind of work.
        >>>So, if I use SQL Server (and assuming I use the code like below, except
        >>>using SqlConnection instead of OLEDbConnection ), most likely I will not
        >>>have the problem where the pool is filling like in Access ? Is the
        >>>maximum pool size in Access smaller than in SQL Server (where the
        >>>default is 100) ?
        >>>>
        >>>I close the connection right after I fill the dataset like shown below.
        >>>Can I close the connection faster then the way I do it ?
        >>>This code is called everytime somebody login to the application.
        >>>>
        >>>Dim cmd As New OleDb.OleDbComm and
        >>>Dim da As OleDb.OleDbData Adapter
        >>>Dim ds As DataSet
        >>>Dim ConnectionDemoO LE As OleDb.OleDbConn ection
        >>>With cmd
        >>> bDBSuccess = OpenDBDemoOLE(C onnectionDemoOL E)
        >>> If bDBSuccess Then
        >>> .Connection = ConnectionDemoO LE
        >>> .CommandText = sql
        >>> Try
        >>> da = New OleDb.OleDbData Adapter
        >>> ds = New DataSet
        >>> da.SelectComman d = cmd
        >>> da.Fill(ds)
        >>> CloseConDemoOLE (ConnectionDemo OLE)
        >>> Catch ex As Exception
        >>> end try
        >>> Sub CloseConDemoOLE (ByRef ConnectionDemoO LE As
        >>>OleDb.OleDbC onnection)
        >>> If Not ConnectionDemoO LE Is Nothing Then
        >>> ConnectionDemoO LE.Close()
        >>> ConnectionDemoO LE = Nothing
        >>> End If
        >>> End Sub
        >>>>
        >>> Function OpenDBDemoOLE(B yRef ConnectionDemoO LE As
        >>>OleDb.OleDbC onnection) As Boolean
        >>> Try
        >>> ConnectionDemoO LE = New OleDb.OleDbConn ection
        >>> OpenDBDemoOLE = True
        >>> With ConnectionDemoO LE
        >>> .ConnectionStri ng = g_dbPathDemo
        >>> .Open()
        >>> If .State = ConnectionState .Closed Then
        >>> CloseConDemoOLE (ConnectionDemo OLE)
        >>> OpenDBDemoOLE = False
        >>> End If
        >>> End With
        >>> Catch ex As Exception
        >>>end try
        >>>>
        >>>"William (Bill) Vaughn" <billva@NoSpamA tAll_betav.comw rote in message
        >>>news:Oroa83Q gHHA.3460@TK2MS FTNGP04.phx.gbl ...
        >>>>Ah, I doubt if this will help. It assumes that the engine has enough
        >>>>idle time to do it's work. The fundamental issue is clear. If the
        >>>>cause of your problem is the CP and the pool is filling then something
        >>>>is overloading the engine or your code is not releasing/closing
        >>>>connectio ns in a timely fashion. Again, JET is not designed for this
        >>>>kind of work. I think you're beating a dead horse.
        >>>>>
        >>>>--
        >>>>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
        >>>>books:
        >>>>Hitchhiker' s Guide to Visual Studio and SQL Server (7th Edition) and
        >>>>Hitchhiker' s Guide to SQL Server 2005 Compact Edition
        >>>>>
        >>>>-----------------------------------------------------------------------------------------------------------------------
        >>>>"fniles" <fniles@pfmail. comwrote in message
        >>>>news:OUmc0j KgHHA.2640@TK2M SFTNGP06.phx.gb l...
        >>>>>Thank you.
        >>>>>I do use try/catch, but I get the "Unspecifie d error".
        >>>>>>
        >>>>>When the maximum pool size has been reached and I get an error, how
        >>>>>can I loop and wait until a connection is available again ?
        >>>>>>
        >>>>> Try
        >>>>> ConnectionOLE = New OleDb.OleDbConn ection
        >>>>> OpenDBOLE = True
        >>>>> With ConnectionOLE
        >>>>> .ConnectionStri ng = g_dbPath
        >>>>> .Open() --IF MAX POOL SIZE HAS BEEN REACHED, IT
        >>>>>WILL GO to the Catch. How can I loop and wait to open the db until a
        >>>>>connecti on is available again ?
        >>>>> End With
        >>>>> Catch ex As Exception
        >>>>> Try
        >>>>>>
        >>>>>Thank you.
        >>>>>>
        >>>>>"William (Bill) Vaughn" <billva@NoSpamA tAll_betav.comw rote in
        >>>>>message news:OlI3%236Hg HHA.4804@TK2MSF TNGP02.phx.gbl. ..
        >>>>>>See >>>>>
        >>>>>>>
        >>>>>>--
        >>>>>>William (Bill) Vaughn
        >>>>>>Author, Mentor, Consultant
        >>>>>>Microso ft 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
        >>>>>>books:
        >>>>>>Hitchhike r's Guide to Visual Studio and SQL Server (7th Edition) and
        >>>>>>Hitchhike r's Guide to SQL Server 2005 Compact Edition
        >>>>>>>
        >>>>>>-----------------------------------------------------------------------------------------------------------------------
        >>>>>>"fniles " <fniles@pfmail. comwrote in message
        >>>>>>news:%23u ACzGHgHHA.4260@ TK2MSFTNGP03.ph x.gbl...
        >>>>>>>>I am using VB.Net 2003 over a LAN, and I have no choice but to use
        >>>>>>>>MS Access.
        >>>>>>>In SQL Server, in the connection string you can set the max pool
        >>>>>>>size, can you do that in MS Access ?
        >>>>>>>
        >>>>>>>>>>>Nope .
        >>>>>>>
        >>>>>>>>
        >>>>>>>You mentioned that "If you exhaust the pool you should get a
        >>>>>>>timeou t exception." So, you will get an error, right ?
        >>>>>>>I mean if you put try-catch-end try, it will go to the Cath
        >>>>>>>sectio n, right ?
        >>>>>>>
        >>>>>>>>>>>Righ t.
        >>>>>>>
        >>>>>>>In my other posting I posted that sometimes I get "Unspecifie d
        >>>>>>>error" on the Open method when opening up the OleDBConnection . This
        >>>>>>>does not happen all the time, only sometimes, which makes me think
        >>>>>>>that maybe the maximum pool size has been reached ? Is it possible
        >>>>>>>that the "Unspecifie d error" on the Open method caused by the
        >>>>>>>maximu m pool size has been reached ?
        >>>>>>>
        >>>>>>>>>>"Unsp ecified" errors generally means you don't have a Try/Catch
        >>>>>>>>>>blo ck to trap the specific exception. In Access/JET, yes it
        >>>>>>>>>>mig ht mean the pool is full or the database is corrupt, or
        >>>>>>>>>>almos t anything else.
        >>>>>>>
        >>>>>>>
        >>>>>>>>
        >>>>>>> Dim swError As StreamWriter
        >>>>>>> Dim sSub As String
        >>>>>>> Try
        >>>>>>> sSub = "1"
        >>>>>>> ConnectionOLE = New OleDb.OleDbConn ection
        >>>>>>> OpenDBOLE = True
        >>>>>>> With ConnectionOLE
        >>>>>>> .ConnectionStri ng = g_dbPath
        >>>>>>> sSub = "2"
        >>>>>>> .Open() --IF MAX POOL SIZE HAS BEEN REACHED, IT
        >>>>>>>WILL GO TO THE Catch section below ?
        >>>>>>>
        >>>>>>>>>In theory... yes.
        >>>>>>>
        >>>>>>>
        >>>>>>> sSub = "3"
        >>>>>>> End With
        >>>>>>> Catch ex As Exception
        >>>>>>> swError = New StreamWriter(Ap plication.Start upPath &
        >>>>>>>"\AQErro rLog" & Date.Now.ToStri ng("MMddyy") & ".txt", True)
        >>>>>>> swError.Write(N ow & " OpenDBOLE - error = " &
        >>>>>>>ex.Messa ge & " sub = " & sSub & " g_dbPath = " & g_dbPath &
        >>>>>>>vbCrLf )
        >>>>>>> swError.Close()
        >>>>>>> swError = Nothing
        >>>>>>> End Try
        >>>>>>>>
        >>>>>>>Thank you.
        >>>>>>>>
        >>>>>>>>
        >>>>>>>>
        >>>>>>>"Willi am (Bill) Vaughn" <billva@NoSpamA tAll_betav.comw rote in
        >>>>>>>messag e news:u2%23Nf5Gg HHA.3388@TK2MSF TNGP02.phx.gbl. ..
        >>>>>>>>>I don't think there are any system counters exposed by the JET
        >>>>>>>>>provid er or by OLE DB to monitor the CP.
        >>>>>>>>If you exhaust the pool you should get a timeout exception.
        >>>>>>>>However , (and Ginny please correct me here), if you're working
        >>>>>>>>with JET and an ASP application, you've got your wires crossed.
        >>>>>>>>JET is not designed to provide data for more than one user. Sure,
        >>>>>>>>you can share a JET .MDB database over a LAN, but each user gets
        >>>>>>>>its own JET engine to access the file. Using it in a web
        >>>>>>>>applica tion that requires one JET engine to access the data is
        >>>>>>>>problem atic at best. I suggest using a DBMS designed for the
        >>>>>>>>web--SQL Express.
        >>>>>>>>>
        >>>>>>>>hth
        >>>>>>>>>
        >>>>>>>>--
        >>>>>>>>Willi am (Bill) Vaughn
        >>>>>>>>Autho r, Mentor, Consultant
        >>>>>>>>Microso ft MVP
        >>>>>>>>INETA Speaker
        >>>>>>>>www.betav.com/blog/billva
        >>>>>>>>www.betav.com
        >>>>>>>>Pleas e 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
        >>>>>>>>lates t books:
        >>>>>>>>Hitchhi ker's Guide to Visual Studio and SQL Server (7th Edition)
        >>>>>>>>and
        >>>>>>>>Hitchhi ker's Guide to SQL Server 2005 Compact Edition
        >>>>>>>>>
        >>>>>>>>-----------------------------------------------------------------------------------------------------------------------
        >>>>>>>>"fniles " <fniles@pfmail. comwrote in message
        >>>>>>>>news:ej DHZzGgHHA.4368@ TK2MSFTNGP03.ph x.gbl...
        >>>>>>>>>>I am using VS2003 and connecting to MS Access database.
        >>>>>>>>>When using a connection pooling (every time I open the
        >>>>>>>>>OLEDBC ONNECTION I use the exact matching connection string),
        >>>>>>>>>1. how can I know how many connection has been used ?
        >>>>>>>>>2. If the maximum pool size has been reached, what happens when I
        >>>>>>>>>call the method Open to open the connection ? Will I get an error
        >>>>>>>>>? MSDN says the request is queued, but will I get an error in the
        >>>>>>>>>open method ?
        >>>>>>>>>>
        >>>>>>>>>Connec tionDemoOLE = New OleDb.OleDbConn ection
        >>>>>>>>>sPat h = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" & sDBPath
        >>>>>>>>>& ";OLE DB
        >>>>>>>>>Servic es=-1"
        >>>>>>>>>With ConnectionDemoO LE
        >>>>>>>>> .ConnectionStri ng = sPath
        >>>>>>>>> .Open() --what happens here when the maximum pool size has
        >>>>>>>>>been reached ?
        >>>>>>>>>>
        >>>>>>>>>Than ks
        >>>>>>>>>>
        >>>>>>>>>>
        >>>>>>>>>
        >>>>>>>>>
        >>>>>>>>
        >>>>>>>>
        >>>>>>>
        >>>>>>>
        >>>>>>
        >>>>>>
        >>>>>
        >>>>>
        >>>>
        >>>>
        >>>
        >>>
        >>
        >>
        >
        >

        Comment

        • William \(Bill\) Vaughn

          #19
          Re: Connection pooling question

          No. Fill opens the connection automatically and closes it afterwards.
          However, if for any reason the connection has already been opened, Fill does
          not change the connection state.

          See >>>

          --
          William (Bill) Vaughn
          Author, Mentor, Consultant
          Microsoft MVP
          INETA Speaker
          Welcome to the home of William Vaughn's Imagination, creations, and advice.

          Welcome to the home of William Vaughn's Imagination, creations, and advice.

          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 books:
          Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition) and
          Hitchhiker's Guide to SQL Server 2005 Compact Edition

          -----------------------------------------------------------------------------------------------------------------------
          "fniles" <fniles@pfmail. comwrote in message
          news:ODZf9tegHH A.4188@TK2MSFTN GP02.phx.gbl...
          Thank you.
          I am sorry I am still not clear on how to call the Fill method without
          opening the connection manually before hand.
          Do you have to open the connection sometime before hand ?
          >
          >Each application gets its own pool. Two applications running on the same
          >machine in different process spaces get their own pool--even if the
          >ConnectionStri ng is the same.
          If for example application A and B uses the same database (either Access
          or
          SQL Server). If maximum connection pooling is 100, each application will
          get 100 maximum connection pooling, is this correct ?
          Connection pools are maintained on a process/application basis. Pools are
          not shared between processes. Again, this assumes that the JET OLE DB
          provider implements pooling. While I suspect it does, the issue has never
          come up because JET when used in a Windows Forms application does not need a
          pool unless you have implemented the application incorrectly.
          >
          I notice when the application uses an Access db on my machine (where no
          other application access that database) my application does not reach the
          maximum pool connection as fast as when I use an Access db on our server
          (where many other applications access that database).
          Is this because even though my application say has maximum of 100
          connections, because other applications access the same database, there
          may
          not be connection available ?
          In a JET architecture where Windows Forms applications are opening the
          database, each client/user gets its own copy of JET to manage the shared
          file. Each client has its own pool and are not sharing any other
          applications' pool. Just because your application opens more than one
          connection, it does not impact the other applications' pool. It DOES impact
          the performance of the application as each JET engine must perform physical
          IO over the LAN to share the database file. This means if your (or any)
          application opens a lot of connections to the datatabase, this puts an
          enormous load on the system and the ability to share the data.

          Remember that JET was designed to support a few users with light load. It
          breaks down quickly when stressed (as you have discovered).

          Again, this is all covered in my earlier books. Considering that MS
          encourages developers to get off of JET for more suitable DBMS engines, I
          suggest you follow their suggestions (and mine).
          >
          "William (Bill) Vaughn" <billva@NoSpamA tAll_betav.comw rote in message
          news:%23B715Ieg HHA.1220@TK2MSF TNGP03.phx.gbl. ..
          >Instantiatin g a Connection object and opening the connection to the data
          >source are two different steps.
          >You can create a global Connection object that's visible to the entire
          >application. In some situations this makes sense--especially in Windows
          >Forms applications.
          >Opening the connection changes the State, links the application to the
          >data source (like opening a file), and permits the application to send
          >queries to the data source (like a DBMS engine).
          >>
          >Each application gets its own pool. Two applications running on the same
          >machine in different process spaces get their own pool--even if the
          >ConnectionStri ng is the same.
          >>
          >>
          >--
          >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
          >books:
          >Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition) and
          >Hitchhiker's Guide to SQL Server 2005 Compact Edition
          >>
          >-----------------------------------------------------------------------------------------------------------------------
          >"fniles" <fniles@pfmail. comwrote in message
          >news:%23zXJj4b gHHA.2400@TK2MS FTNGP04.phx.gbl ...
          >>Thank you one more time. You are very helpful.
          >>You suggested to not open the connection manually. How do you do that ?
          >>Don't I need to assign a connection to the OleDbCommand ?
          >>You mentioned the Fill method opens the connection, how does it know
          >>what connection ?
          >>>
          >>Will my code than look something like below :
          >>>
          >>Dim cmd As New OleDb.OleDbComm and
          >>Dim da As OleDb.OleDbData Adapter
          >>Dim ds As DataSet
          >>Dim ConnectionDemoO LE As OleDb.OleDbConn ection
          >>With cmd
          >> '----DO NOT NEED THIS CODE ----- bDBSuccess =
          >>OpenDBDemoOLE (ConnectionDemo OLE) ------'
          >> '----If bDBSuccess Then
          >> .Connection = ConnectionDemoO LE '????
          >> .CommandText = sql
          >> Try
          >> da = New OleDb.OleDbData Adapter
          >> ds = New DataSet
          >> da.SelectComman d = cmd
          >> da.Fill(ds)
          >> CloseConDemoOLE (ConnectionDemo OLE)
          >> Catch ex As Exception
          >> end try
          >>>
          >>Thank you.
          >>>
          >>"William (Bill) Vaughn" <billva@NoSpamA tAll_betav.comw rote in message
          >>news:ulZ4z6Ug HHA.1388@TK2MSF TNGP05.phx.gbl. ..
          >>>CP::Connecti on Pool
          >>>The differences between JET and SQL Server are ... well, dramatic. They
          >>>are designed very differently. JET is a throw-back to shared-file ISAM
          >>>(dBASE) database engines (circa 1970's) while SQL Server is a
          >>>service-based engine designed to handle many, many users and far more
          >>>secure and scalable database requirements. I characterize JET as a
          >>>"home" database and I don't recommend it for any (serious) business
          >>>applicatio ns--despite the fact that it's in very wide use all over the
          >>>world in lots of businesses. It makes a sad web DBMS engine. While it
          >>>can work, you're likely to see more and more serious (unsolvable)
          >>>problems with JET when used incorrectly.
          >>>>
          >>>Will SQL Server tolerate code that does not properly close connections?
          >>>Nope, its connection pool will overflow if you don't write the
          >>>applicatio n correctly. Will it expose more counters and trace metrics
          >>>to let you inspect the CP status? Sure and then some. Is it designed
          >>>for use in a web site? Absolutely.
          >>>>
          >>>I looked at your code (again) and I see that you're manually opening
          >>>the connection. You don't have to. In your case I suggest that you
          >>>don't. The Fill method opens the connection (if it's not already open),
          >>>runs the query, populates the DataSet and closes the connection (if it
          >>>was opened by Fill).
          >>>>
          >>>I still suspect you might be over-running the ability of JET to handle
          >>>the workload. Remember JET can't stop work on a query and service
          >>>another request. All requests are handled serially (unlike SQL Server).
          >>>>
          >>>I discuss all of this and more in my latest book.
          >>>>
          >>>--
          >>>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
          >>>books:
          >>>Hitchhiker 's Guide to Visual Studio and SQL Server (7th Edition) and
          >>>Hitchhiker 's Guide to SQL Server 2005 Compact Edition
          >>>>
          >>>-----------------------------------------------------------------------------------------------------------------------
          >>>"fniles" <fniles@pfmail. comwrote in message
          >>>news:ego1grR gHHA.3960@TK2MS FTNGP02.phx.gbl ...
          >>>>Thank you.
          >>>>>>If the cause of your problem is the CP
          >>>>What did you mean by CP ?
          >>>>>
          >>>>>>JET is not designed for this kind of work.
          >>>>So, if I use SQL Server (and assuming I use the code like below,
          >>>>except using SqlConnection instead of OLEDbConnection ), most likely I
          >>>>will not have the problem where the pool is filling like in Access ?
          >>>>Is the maximum pool size in Access smaller than in SQL Server (where
          >>>>the default is 100) ?
          >>>>>
          >>>>I close the connection right after I fill the dataset like shown
          >>>>below. Can I close the connection faster then the way I do it ?
          >>>>This code is called everytime somebody login to the application.
          >>>>>
          >>>>Dim cmd As New OleDb.OleDbComm and
          >>>>Dim da As OleDb.OleDbData Adapter
          >>>>Dim ds As DataSet
          >>>>Dim ConnectionDemoO LE As OleDb.OleDbConn ection
          >>>>With cmd
          >>>> bDBSuccess = OpenDBDemoOLE(C onnectionDemoOL E)
          >>>> If bDBSuccess Then
          >>>> .Connection = ConnectionDemoO LE
          >>>> .CommandText = sql
          >>>> Try
          >>>> da = New OleDb.OleDbData Adapter
          >>>> ds = New DataSet
          >>>> da.SelectComman d = cmd
          >>>> da.Fill(ds)
          >>>> CloseConDemoOLE (ConnectionDemo OLE)
          >>>> Catch ex As Exception
          >>>> end try
          >>>> Sub CloseConDemoOLE (ByRef ConnectionDemoO LE As
          >>>>OleDb.OleDb Connection)
          >>>> If Not ConnectionDemoO LE Is Nothing Then
          >>>> ConnectionDemoO LE.Close()
          >>>> ConnectionDemoO LE = Nothing
          >>>> End If
          >>>> End Sub
          >>>>>
          >>>> Function OpenDBDemoOLE(B yRef ConnectionDemoO LE As
          >>>>OleDb.OleDb Connection) As Boolean
          >>>> Try
          >>>> ConnectionDemoO LE = New OleDb.OleDbConn ection
          >>>> OpenDBDemoOLE = True
          >>>> With ConnectionDemoO LE
          >>>> .ConnectionStri ng = g_dbPathDemo
          >>>> .Open()
          >>>> If .State = ConnectionState .Closed Then
          >>>> CloseConDemoOLE (ConnectionDemo OLE)
          >>>> OpenDBDemoOLE = False
          >>>> End If
          >>>> End With
          >>>> Catch ex As Exception
          >>>>end try
          >>>>>
          >>>>"William (Bill) Vaughn" <billva@NoSpamA tAll_betav.comw rote in
          >>>>message news:Oroa83QgHH A.3460@TK2MSFTN GP04.phx.gbl...
          >>>>>Ah, I doubt if this will help. It assumes that the engine has enough
          >>>>>idle time to do it's work. The fundamental issue is clear. If the
          >>>>>cause of your problem is the CP and the pool is filling then
          >>>>>somethin g is overloading the engine or your code is not
          >>>>>releasin g/closing connections in a timely fashion. Again, JET is not
          >>>>>designed for this kind of work. I think you're beating a dead horse.
          >>>>>>
          >>>>>--
          >>>>>William (Bill) Vaughn
          >>>>>Author, Mentor, Consultant
          >>>>>Microsof t 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
          >>>>>books:
          >>>>>Hitchhiker 's Guide to Visual Studio and SQL Server (7th Edition) and
          >>>>>Hitchhiker 's Guide to SQL Server 2005 Compact Edition
          >>>>>>
          >>>>>-----------------------------------------------------------------------------------------------------------------------
          >>>>>"fniles" <fniles@pfmail. comwrote in message
          >>>>>news:OUmc0 jKgHHA.2640@TK2 MSFTNGP06.phx.g bl...
          >>>>>>Thank you.
          >>>>>>I do use try/catch, but I get the "Unspecifie d error".
          >>>>>>>
          >>>>>>When the maximum pool size has been reached and I get an error, how
          >>>>>>can I loop and wait until a connection is available again ?
          >>>>>>>
          >>>>>> Try
          >>>>>> ConnectionOLE = New OleDb.OleDbConn ection
          >>>>>> OpenDBOLE = True
          >>>>>> With ConnectionOLE
          >>>>>> .ConnectionStri ng = g_dbPath
          >>>>>> .Open() --IF MAX POOL SIZE HAS BEEN REACHED, IT
          >>>>>>WILL GO to the Catch. How can I loop and wait to open the db until a
          >>>>>>connectio n is available again ?
          >>>>>> End With
          >>>>>> Catch ex As Exception
          >>>>>> Try
          >>>>>>>
          >>>>>>Thank you.
          >>>>>>>
          >>>>>>"Willia m (Bill) Vaughn" <billva@NoSpamA tAll_betav.comw rote in
          >>>>>>message news:OlI3%236Hg HHA.4804@TK2MSF TNGP02.phx.gbl. ..
          >>>>>>>See >>>>>
          >>>>>>>>
          >>>>>>>--
          >>>>>>>Willia m (Bill) Vaughn
          >>>>>>>Author , Mentor, Consultant
          >>>>>>>Microsof t 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
          >>>>>>>books:
          >>>>>>>Hitchhik er's Guide to Visual Studio and SQL Server (7th Edition)
          >>>>>>>and
          >>>>>>>Hitchhik er's Guide to SQL Server 2005 Compact Edition
          >>>>>>>>
          >>>>>>>-----------------------------------------------------------------------------------------------------------------------
          >>>>>>>"fnile s" <fniles@pfmail. comwrote in message
          >>>>>>>news:%23 uACzGHgHHA.4260 @TK2MSFTNGP03.p hx.gbl...
          >>>>>>>>>I am using VB.Net 2003 over a LAN, and I have no choice but to use
          >>>>>>>>>MS Access.
          >>>>>>>>In SQL Server, in the connection string you can set the max pool
          >>>>>>>>size, can you do that in MS Access ?
          >>>>>>>>
          >>>>>>>>>>>>Nop e.
          >>>>>>>>
          >>>>>>>>>
          >>>>>>>>You mentioned that "If you exhaust the pool you should get a
          >>>>>>>>timeo ut exception." So, you will get an error, right ?
          >>>>>>>>I mean if you put try-catch-end try, it will go to the Cath
          >>>>>>>>section , right ?
          >>>>>>>>
          >>>>>>>>>>>>Rig ht.
          >>>>>>>>
          >>>>>>>>In my other posting I posted that sometimes I get "Unspecifie d
          >>>>>>>>error " on the Open method when opening up the OleDBConnection .
          >>>>>>>>This does not happen all the time, only sometimes, which makes me
          >>>>>>>>think that maybe the maximum pool size has been reached ? Is it
          >>>>>>>>possibl e that the "Unspecifie d error" on the Open method caused by
          >>>>>>>>the maximum pool size has been reached ?
          >>>>>>>>
          >>>>>>>>>>>"Uns pecified" errors generally means you don't have a Try/Catch
          >>>>>>>>>>>bloc k to trap the specific exception. In Access/JET, yes it
          >>>>>>>>>>>migh t mean the pool is full or the database is corrupt, or
          >>>>>>>>>>>almo st anything else.
          >>>>>>>>
          >>>>>>>>
          >>>>>>>>>
          >>>>>>>> Dim swError As StreamWriter
          >>>>>>>> Dim sSub As String
          >>>>>>>> Try
          >>>>>>>> sSub = "1"
          >>>>>>>> ConnectionOLE = New OleDb.OleDbConn ection
          >>>>>>>> OpenDBOLE = True
          >>>>>>>> With ConnectionOLE
          >>>>>>>> .ConnectionStri ng = g_dbPath
          >>>>>>>> sSub = "2"
          >>>>>>>> .Open() --IF MAX POOL SIZE HAS BEEN REACHED, IT
          >>>>>>>>WILL GO TO THE Catch section below ?
          >>>>>>>>
          >>>>>>>>>>In theory... yes.
          >>>>>>>>
          >>>>>>>>
          >>>>>>>> sSub = "3"
          >>>>>>>> End With
          >>>>>>>> Catch ex As Exception
          >>>>>>>> swError = New StreamWriter(Ap plication.Start upPath
          >>>>>>>>& "\AQErrorLo g" & Date.Now.ToStri ng("MMddyy") & ".txt", True)
          >>>>>>>> swError.Write(N ow & " OpenDBOLE - error = " &
          >>>>>>>>ex.Mess age & " sub = " & sSub & " g_dbPath = " & g_dbPath &
          >>>>>>>>vbCrL f)
          >>>>>>>> swError.Close()
          >>>>>>>> swError = Nothing
          >>>>>>>> End Try
          >>>>>>>>>
          >>>>>>>>Thank you.
          >>>>>>>>>
          >>>>>>>>>
          >>>>>>>>>
          >>>>>>>>"Willia m (Bill) Vaughn" <billva@NoSpamA tAll_betav.comw rote in
          >>>>>>>>messa ge news:u2%23Nf5Gg HHA.3388@TK2MSF TNGP02.phx.gbl. ..
          >>>>>>>>>>I don't think there are any system counters exposed by the JET
          >>>>>>>>>>provi der or by OLE DB to monitor the CP.
          >>>>>>>>>If you exhaust the pool you should get a timeout exception.
          >>>>>>>>>Howeve r, (and Ginny please correct me here), if you're working
          >>>>>>>>>with JET and an ASP application, you've got your wires crossed.
          >>>>>>>>>JET is not designed to provide data for more than one user. Sure,
          >>>>>>>>>you can share a JET .MDB database over a LAN, but each user gets
          >>>>>>>>>its own JET engine to access the file. Using it in a web
          >>>>>>>>>applic ation that requires one JET engine to access the data is
          >>>>>>>>>proble matic at best. I suggest using a DBMS designed for the
          >>>>>>>>>web--SQL Express.
          >>>>>>>>>>
          >>>>>>>>>hth
          >>>>>>>>>>
          >>>>>>>>>--
          >>>>>>>>>Willia m (Bill) Vaughn
          >>>>>>>>>Author , Mentor, Consultant
          >>>>>>>>>Micros oft MVP
          >>>>>>>>>INET A Speaker
          >>>>>>>>>www.betav.com/blog/billva
          >>>>>>>>>www.betav.com
          >>>>>>>>>Plea se reply only to the newsgroup so that others can benefit.
          >>>>>>>>>This posting is provided "AS IS" with no warranties, and confers
          >>>>>>>>>no rights.
          >>>>>>>>>______ _______________ _____________
          >>>>>>>>>Visi t www.hitchhikerguides.net to get more information on my
          >>>>>>>>>late st books:
          >>>>>>>>>Hitchh iker's Guide to Visual Studio and SQL Server (7th Edition)
          >>>>>>>>>and
          >>>>>>>>>Hitchh iker's Guide to SQL Server 2005 Compact Edition
          >>>>>>>>>>
          >>>>>>>>>-----------------------------------------------------------------------------------------------------------------------
          >>>>>>>>>"fnile s" <fniles@pfmail. comwrote in message
          >>>>>>>>>news:e jDHZzGgHHA.4368 @TK2MSFTNGP03.p hx.gbl...
          >>>>>>>>>>>I am using VS2003 and connecting to MS Access database.
          >>>>>>>>>>Whe n using a connection pooling (every time I open the
          >>>>>>>>>>OLEDB CONNECTION I use the exact matching connection string),
          >>>>>>>>>>1. how can I know how many connection has been used ?
          >>>>>>>>>>2. If the maximum pool size has been reached, what happens when
          >>>>>>>>>>I call the method Open to open the connection ? Will I get an
          >>>>>>>>>>err or ? MSDN says the request is queued, but will I get an error
          >>>>>>>>>>in the open method ?
          >>>>>>>>>>>
          >>>>>>>>>>Conne ctionDemoOLE = New OleDb.OleDbConn ection
          >>>>>>>>>>sPa th = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" &
          >>>>>>>>>>sDBPa th & ";OLE DB
          >>>>>>>>>>Servi ces=-1"
          >>>>>>>>>>Wit h ConnectionDemoO LE
          >>>>>>>>>> .ConnectionStri ng = sPath
          >>>>>>>>>> .Open() --what happens here when the maximum pool size has
          >>>>>>>>>>bee n reached ?
          >>>>>>>>>>>
          >>>>>>>>>>Thank s
          >>>>>>>>>>>
          >>>>>>>>>>>
          >>>>>>>>>>
          >>>>>>>>>>
          >>>>>>>>>
          >>>>>>>>>
          >>>>>>>>
          >>>>>>>>
          >>>>>>>
          >>>>>>>
          >>>>>>
          >>>>>>
          >>>>>
          >>>>>
          >>>>
          >>>>
          >>>
          >>>
          >>
          >>
          >
          >

          Comment

          • fniles

            #20
            Re: Connection pooling question

            No. Fill opens the connection automatically and closes it afterwards.
            I am sorry, but how does Fill know which connection to use ?
            Do you have a sample code on how to just do fill without assigning a
            connection to the OLEDbCommand object ? Thanks so much for your help.
            These are my original codes:
            Dim cmd As New OleDb.OleDbComm and
            Dim da As OleDb.OleDbData Adapter
            Dim ds As DataSet
            Dim ConnectionDemoO LE As OleDb.OleDbConn ection
            With cmd
            bDBSuccess = OpenDBDemoOLE(C onnectionDemoOL E)
            If bDBSuccess Then
            .Connection = ConnectionDemoO LE
            .CommandText = sql
            da = New OleDb.OleDbData Adapter
            ds = New DataSet
            da.SelectComman d = cmd
            da.Fill(ds)
            :


            "William (Bill) Vaughn" <billva@NoSpamA tAll_betav.comw rote in message
            news:uH81BlfgHH A.2396@TK2MSFTN GP04.phx.gbl...
            No. Fill opens the connection automatically and closes it afterwards.
            However, if for any reason the connection has already been opened, Fill
            does not change the connection state.
            >
            See >>>
            >
            --
            William (Bill) Vaughn
            Author, Mentor, Consultant
            Microsoft MVP
            INETA Speaker
            Welcome to the home of William Vaughn's Imagination, creations, and advice.

            Welcome to the home of William Vaughn's Imagination, creations, and advice.

            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 books:
            Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition) and
            Hitchhiker's Guide to SQL Server 2005 Compact Edition
            >
            -----------------------------------------------------------------------------------------------------------------------
            "fniles" <fniles@pfmail. comwrote in message
            news:ODZf9tegHH A.4188@TK2MSFTN GP02.phx.gbl...
            >Thank you.
            >I am sorry I am still not clear on how to call the Fill method without
            >opening the connection manually before hand.
            >Do you have to open the connection sometime before hand ?
            >>
            >>Each application gets its own pool. Two applications running on the same
            >>machine in different process spaces get their own pool--even if the
            >>ConnectionStr ing is the same.
            >If for example application A and B uses the same database (either Access
            >or
            >SQL Server). If maximum connection pooling is 100, each application will
            >get 100 maximum connection pooling, is this correct ?
            >
            Connection pools are maintained on a process/application basis. Pools are
            not shared between processes. Again, this assumes that the JET OLE DB
            provider implements pooling. While I suspect it does, the issue has never
            come up because JET when used in a Windows Forms application does not need
            a pool unless you have implemented the application incorrectly.
            >
            >>
            >I notice when the application uses an Access db on my machine (where no
            >other application access that database) my application does not reach the
            >maximum pool connection as fast as when I use an Access db on our server
            >(where many other applications access that database).
            >Is this because even though my application say has maximum of 100
            >connections, because other applications access the same database, there
            >may
            >not be connection available ?
            >
            In a JET architecture where Windows Forms applications are opening the
            database, each client/user gets its own copy of JET to manage the shared
            file. Each client has its own pool and are not sharing any other
            applications' pool. Just because your application opens more than one
            connection, it does not impact the other applications' pool. It DOES
            impact the performance of the application as each JET engine must perform
            physical IO over the LAN to share the database file. This means if your
            (or any) application opens a lot of connections to the datatabase, this
            puts an enormous load on the system and the ability to share the data.
            >
            Remember that JET was designed to support a few users with light load. It
            breaks down quickly when stressed (as you have discovered).
            >
            Again, this is all covered in my earlier books. Considering that MS
            encourages developers to get off of JET for more suitable DBMS engines, I
            suggest you follow their suggestions (and mine).
            >
            >>
            >"William (Bill) Vaughn" <billva@NoSpamA tAll_betav.comw rote in message
            >news:%23B715Ie gHHA.1220@TK2MS FTNGP03.phx.gbl ...
            >>Instantiati ng a Connection object and opening the connection to the data
            >>source are two different steps.
            >>You can create a global Connection object that's visible to the entire
            >>application . In some situations this makes sense--especially in Windows
            >>Forms applications.
            >>Opening the connection changes the State, links the application to the
            >>data source (like opening a file), and permits the application to send
            >>queries to the data source (like a DBMS engine).
            >>>
            >>Each application gets its own pool. Two applications running on the same
            >>machine in different process spaces get their own pool--even if the
            >>ConnectionStr ing is the same.
            >>>
            >>>
            >>--
            >>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
            >>books:
            >>Hitchhiker' s Guide to Visual Studio and SQL Server (7th Edition) and
            >>Hitchhiker' s Guide to SQL Server 2005 Compact Edition
            >>>
            >>-----------------------------------------------------------------------------------------------------------------------
            >>"fniles" <fniles@pfmail. comwrote in message
            >>news:%23zXJj4 bgHHA.2400@TK2M SFTNGP04.phx.gb l...
            >>>Thank you one more time. You are very helpful.
            >>>You suggested to not open the connection manually. How do you do that ?
            >>>Don't I need to assign a connection to the OleDbCommand ?
            >>>You mentioned the Fill method opens the connection, how does it know
            >>>what connection ?
            >>>>
            >>>Will my code than look something like below :
            >>>>
            >>>Dim cmd As New OleDb.OleDbComm and
            >>>Dim da As OleDb.OleDbData Adapter
            >>>Dim ds As DataSet
            >>>Dim ConnectionDemoO LE As OleDb.OleDbConn ection
            >>>With cmd
            >>> '----DO NOT NEED THIS CODE ----- bDBSuccess =
            >>>OpenDBDemoOL E(ConnectionDem oOLE) ------'
            >>> '----If bDBSuccess Then
            >>> .Connection = ConnectionDemoO LE '????
            >>> .CommandText = sql
            >>> Try
            >>> da = New OleDb.OleDbData Adapter
            >>> ds = New DataSet
            >>> da.SelectComman d = cmd
            >>> da.Fill(ds)
            >>> CloseConDemoOLE (ConnectionDemo OLE)
            >>> Catch ex As Exception
            >>> end try
            >>>>
            >>>Thank you.
            >>>>
            >>>"William (Bill) Vaughn" <billva@NoSpamA tAll_betav.comw rote in message
            >>>news:ulZ4z6U gHHA.1388@TK2MS FTNGP05.phx.gbl ...
            >>>>CP::Connect ion Pool
            >>>>The differences between JET and SQL Server are ... well, dramatic.
            >>>>They are designed very differently. JET is a throw-back to shared-file
            >>>>ISAM (dBASE) database engines (circa 1970's) while SQL Server is a
            >>>>service-based engine designed to handle many, many users and far more
            >>>>secure and scalable database requirements. I characterize JET as a
            >>>>"home" database and I don't recommend it for any (serious) business
            >>>>application s--despite the fact that it's in very wide use all over the
            >>>>world in lots of businesses. It makes a sad web DBMS engine. While it
            >>>>can work, you're likely to see more and more serious (unsolvable)
            >>>>problems with JET when used incorrectly.
            >>>>>
            >>>>Will SQL Server tolerate code that does not properly close
            >>>>connections ? Nope, its connection pool will overflow if you don't
            >>>>write the application correctly. Will it expose more counters and
            >>>>trace metrics to let you inspect the CP status? Sure and then some. Is
            >>>>it designed for use in a web site? Absolutely.
            >>>>>
            >>>>I looked at your code (again) and I see that you're manually opening
            >>>>the connection. You don't have to. In your case I suggest that you
            >>>>don't. The Fill method opens the connection (if it's not already
            >>>>open), runs the query, populates the DataSet and closes the connection
            >>>>(if it was opened by Fill).
            >>>>>
            >>>>I still suspect you might be over-running the ability of JET to handle
            >>>>the workload. Remember JET can't stop work on a query and service
            >>>>another request. All requests are handled serially (unlike SQL
            >>>>Server).
            >>>>>
            >>>>I discuss all of this and more in my latest book.
            >>>>>
            >>>>--
            >>>>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
            >>>>books:
            >>>>Hitchhiker' s Guide to Visual Studio and SQL Server (7th Edition) and
            >>>>Hitchhiker' s Guide to SQL Server 2005 Compact Edition
            >>>>>
            >>>>-----------------------------------------------------------------------------------------------------------------------
            >>>>"fniles" <fniles@pfmail. comwrote in message
            >>>>news:ego1gr RgHHA.3960@TK2M SFTNGP02.phx.gb l...
            >>>>>Thank you.
            >>>>>>>If the cause of your problem is the CP
            >>>>>What did you mean by CP ?
            >>>>>>
            >>>>>>>JET is not designed for this kind of work.
            >>>>>So, if I use SQL Server (and assuming I use the code like below,
            >>>>>except using SqlConnection instead of OLEDbConnection ), most likely I
            >>>>>will not have the problem where the pool is filling like in Access ?
            >>>>>Is the maximum pool size in Access smaller than in SQL Server (where
            >>>>>the default is 100) ?
            >>>>>>
            >>>>>I close the connection right after I fill the dataset like shown
            >>>>>below. Can I close the connection faster then the way I do it ?
            >>>>>This code is called everytime somebody login to the application.
            >>>>>>
            >>>>>Dim cmd As New OleDb.OleDbComm and
            >>>>>Dim da As OleDb.OleDbData Adapter
            >>>>>Dim ds As DataSet
            >>>>>Dim ConnectionDemoO LE As OleDb.OleDbConn ection
            >>>>>With cmd
            >>>>> bDBSuccess = OpenDBDemoOLE(C onnectionDemoOL E)
            >>>>> If bDBSuccess Then
            >>>>> .Connection = ConnectionDemoO LE
            >>>>> .CommandText = sql
            >>>>> Try
            >>>>> da = New OleDb.OleDbData Adapter
            >>>>> ds = New DataSet
            >>>>> da.SelectComman d = cmd
            >>>>> da.Fill(ds)
            >>>>> CloseConDemoOLE (ConnectionDemo OLE)
            >>>>> Catch ex As Exception
            >>>>> end try
            >>>>> Sub CloseConDemoOLE (ByRef ConnectionDemoO LE As
            >>>>>OleDb.OleD bConnection)
            >>>>> If Not ConnectionDemoO LE Is Nothing Then
            >>>>> ConnectionDemoO LE.Close()
            >>>>> ConnectionDemoO LE = Nothing
            >>>>> End If
            >>>>> End Sub
            >>>>>>
            >>>>> Function OpenDBDemoOLE(B yRef ConnectionDemoO LE As
            >>>>>OleDb.OleD bConnection) As Boolean
            >>>>> Try
            >>>>> ConnectionDemoO LE = New OleDb.OleDbConn ection
            >>>>> OpenDBDemoOLE = True
            >>>>> With ConnectionDemoO LE
            >>>>> .ConnectionStri ng = g_dbPathDemo
            >>>>> .Open()
            >>>>> If .State = ConnectionState .Closed Then
            >>>>> CloseConDemoOLE (ConnectionDemo OLE)
            >>>>> OpenDBDemoOLE = False
            >>>>> End If
            >>>>> End With
            >>>>> Catch ex As Exception
            >>>>>end try
            >>>>>>
            >>>>>"William (Bill) Vaughn" <billva@NoSpamA tAll_betav.comw rote in
            >>>>>message news:Oroa83QgHH A.3460@TK2MSFTN GP04.phx.gbl...
            >>>>>>Ah, I doubt if this will help. It assumes that the engine has enough
            >>>>>>idle time to do it's work. The fundamental issue is clear. If the
            >>>>>>cause of your problem is the CP and the pool is filling then
            >>>>>>somethi ng is overloading the engine or your code is not
            >>>>>>releasi ng/closing connections in a timely fashion. Again, JET is not
            >>>>>>designe d for this kind of work. I think you're beating a dead horse.
            >>>>>>>
            >>>>>>--
            >>>>>>William (Bill) Vaughn
            >>>>>>Author, Mentor, Consultant
            >>>>>>Microso ft 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
            >>>>>>books:
            >>>>>>Hitchhike r's Guide to Visual Studio and SQL Server (7th Edition) and
            >>>>>>Hitchhike r's Guide to SQL Server 2005 Compact Edition
            >>>>>>>
            >>>>>>-----------------------------------------------------------------------------------------------------------------------
            >>>>>>"fniles " <fniles@pfmail. comwrote in message
            >>>>>>news:OUmc 0jKgHHA.2640@TK 2MSFTNGP06.phx. gbl...
            >>>>>>>Thank you.
            >>>>>>>I do use try/catch, but I get the "Unspecifie d error".
            >>>>>>>>
            >>>>>>>When the maximum pool size has been reached and I get an error, how
            >>>>>>>can I loop and wait until a connection is available again ?
            >>>>>>>>
            >>>>>>> Try
            >>>>>>> ConnectionOLE = New OleDb.OleDbConn ection
            >>>>>>> OpenDBOLE = True
            >>>>>>> With ConnectionOLE
            >>>>>>> .ConnectionStri ng = g_dbPath
            >>>>>>> .Open() --IF MAX POOL SIZE HAS BEEN REACHED, IT
            >>>>>>>WILL GO to the Catch. How can I loop and wait to open the db until
            >>>>>>>a connection is available again ?
            >>>>>>> End With
            >>>>>>> Catch ex As Exception
            >>>>>>> Try
            >>>>>>>>
            >>>>>>>Thank you.
            >>>>>>>>
            >>>>>>>"Willi am (Bill) Vaughn" <billva@NoSpamA tAll_betav.comw rote in
            >>>>>>>messag e news:OlI3%236Hg HHA.4804@TK2MSF TNGP02.phx.gbl. ..
            >>>>>>>>See >>>>>
            >>>>>>>>>
            >>>>>>>>--
            >>>>>>>>Willi am (Bill) Vaughn
            >>>>>>>>Autho r, Mentor, Consultant
            >>>>>>>>Microso ft MVP
            >>>>>>>>INETA Speaker
            >>>>>>>>www.betav.com/blog/billva
            >>>>>>>>www.betav.com
            >>>>>>>>Pleas e 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
            >>>>>>>>lates t books:
            >>>>>>>>Hitchhi ker's Guide to Visual Studio and SQL Server (7th Edition)
            >>>>>>>>and
            >>>>>>>>Hitchhi ker's Guide to SQL Server 2005 Compact Edition
            >>>>>>>>>
            >>>>>>>>-----------------------------------------------------------------------------------------------------------------------
            >>>>>>>>"fniles " <fniles@pfmail. comwrote in message
            >>>>>>>>news:%2 3uACzGHgHHA.426 0@TK2MSFTNGP03. phx.gbl...
            >>>>>>>>>>I am using VB.Net 2003 over a LAN, and I have no choice but to use
            >>>>>>>>>>MS Access.
            >>>>>>>>>In SQL Server, in the connection string you can set the max pool
            >>>>>>>>>size , can you do that in MS Access ?
            >>>>>>>>>
            >>>>>>>>>>>>>No pe.
            >>>>>>>>>
            >>>>>>>>>>
            >>>>>>>>>You mentioned that "If you exhaust the pool you should get a
            >>>>>>>>>timeou t exception." So, you will get an error, right ?
            >>>>>>>>>I mean if you put try-catch-end try, it will go to the Cath
            >>>>>>>>>sectio n, right ?
            >>>>>>>>>
            >>>>>>>>>>>>>Ri ght.
            >>>>>>>>>
            >>>>>>>>>In my other posting I posted that sometimes I get "Unspecifie d
            >>>>>>>>>erro r" on the Open method when opening up the OleDBConnection .
            >>>>>>>>>This does not happen all the time, only sometimes, which makes me
            >>>>>>>>>thin k that maybe the maximum pool size has been reached ? Is it
            >>>>>>>>>possib le that the "Unspecifie d error" on the Open method caused
            >>>>>>>>>by the maximum pool size has been reached ?
            >>>>>>>>>
            >>>>>>>>>>>>"Un specified" errors generally means you don't have a
            >>>>>>>>>>>>T ry/Catch block to trap the specific exception. In Access/JET,
            >>>>>>>>>>>>y es it might mean the pool is full or the database is corrupt,
            >>>>>>>>>>>>o r almost anything else.
            >>>>>>>>>
            >>>>>>>>>
            >>>>>>>>>>
            >>>>>>>>> Dim swError As StreamWriter
            >>>>>>>>> Dim sSub As String
            >>>>>>>>> Try
            >>>>>>>>> sSub = "1"
            >>>>>>>>> ConnectionOLE = New OleDb.OleDbConn ection
            >>>>>>>>> OpenDBOLE = True
            >>>>>>>>> With ConnectionOLE
            >>>>>>>>> .ConnectionStri ng = g_dbPath
            >>>>>>>>> sSub = "2"
            >>>>>>>>> .Open() --IF MAX POOL SIZE HAS BEEN REACHED, IT
            >>>>>>>>>WILL GO TO THE Catch section below ?
            >>>>>>>>>
            >>>>>>>>>>>In theory... yes.
            >>>>>>>>>
            >>>>>>>>>
            >>>>>>>>> sSub = "3"
            >>>>>>>>> End With
            >>>>>>>>> Catch ex As Exception
            >>>>>>>>> swError = New StreamWriter(Ap plication.Start upPath
            >>>>>>>>>& "\AQErrorLo g" & Date.Now.ToStri ng("MMddyy") & ".txt", True)
            >>>>>>>>> swError.Write(N ow & " OpenDBOLE - error = " &
            >>>>>>>>>ex.Mes sage & " sub = " & sSub & " g_dbPath = " & g_dbPath &
            >>>>>>>>>vbCrLf )
            >>>>>>>>> swError.Close()
            >>>>>>>>> swError = Nothing
            >>>>>>>>> End Try
            >>>>>>>>>>
            >>>>>>>>>Than k you.
            >>>>>>>>>>
            >>>>>>>>>>
            >>>>>>>>>>
            >>>>>>>>>"Willi am (Bill) Vaughn" <billva@NoSpamA tAll_betav.comw rote in
            >>>>>>>>>messag e news:u2%23Nf5Gg HHA.3388@TK2MSF TNGP02.phx.gbl. ..
            >>>>>>>>>>>I don't think there are any system counters exposed by the JET
            >>>>>>>>>>>prov ider or by OLE DB to monitor the CP.
            >>>>>>>>>>If you exhaust the pool you should get a timeout exception.
            >>>>>>>>>>Howev er, (and Ginny please correct me here), if you're working
            >>>>>>>>>>wit h JET and an ASP application, you've got your wires crossed.
            >>>>>>>>>>JET is not designed to provide data for more than one user.
            >>>>>>>>>>Sur e, you can share a JET .MDB database over a LAN, but each
            >>>>>>>>>>use r gets its own JET engine to access the file. Using it in a
            >>>>>>>>>>web application that requires one JET engine to access the data
            >>>>>>>>>>is problematic at best. I suggest using a DBMS designed for the
            >>>>>>>>>>web--SQL Express.
            >>>>>>>>>>>
            >>>>>>>>>>hth
            >>>>>>>>>>>
            >>>>>>>>>>--
            >>>>>>>>>>Willi am (Bill) Vaughn
            >>>>>>>>>>Autho r, Mentor, Consultant
            >>>>>>>>>>Micro soft MVP
            >>>>>>>>>>INE TA Speaker
            >>>>>>>>>>www.betav.com/blog/billva
            >>>>>>>>>>www.betav.com
            >>>>>>>>>>Pleas e reply only to the newsgroup so that others can benefit.
            >>>>>>>>>>Thi s posting is provided "AS IS" with no warranties, and confers
            >>>>>>>>>>no rights.
            >>>>>>>>>>_____ _______________ ______________
            >>>>>>>>>>Vis it www.hitchhikerguides.net to get more information on my
            >>>>>>>>>>lates t books:
            >>>>>>>>>>Hitch hiker's Guide to Visual Studio and SQL Server (7th Edition)
            >>>>>>>>>>and
            >>>>>>>>>>Hitch hiker's Guide to SQL Server 2005 Compact Edition
            >>>>>>>>>>>
            >>>>>>>>>>-----------------------------------------------------------------------------------------------------------------------
            >>>>>>>>>>"fnil es" <fniles@pfmail. comwrote in message
            >>>>>>>>>>news: ejDHZzGgHHA.436 8@TK2MSFTNGP03. phx.gbl...
            >>>>>>>>>>>>I am using VS2003 and connecting to MS Access database.
            >>>>>>>>>>>Wh en using a connection pooling (every time I open the
            >>>>>>>>>>>OLED BCONNECTION I use the exact matching connection string),
            >>>>>>>>>>>1. how can I know how many connection has been used ?
            >>>>>>>>>>>2. If the maximum pool size has been reached, what happens when
            >>>>>>>>>>>I call the method Open to open the connection ? Will I get an
            >>>>>>>>>>>erro r ? MSDN says the request is queued, but will I get an
            >>>>>>>>>>>erro r in the open method ?
            >>>>>>>>>>>>
            >>>>>>>>>>>Conn ectionDemoOLE = New OleDb.OleDbConn ection
            >>>>>>>>>>>sPat h = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" &
            >>>>>>>>>>>sDBP ath & ";OLE DB
            >>>>>>>>>>>Serv ices=-1"
            >>>>>>>>>>>Wi th ConnectionDemoO LE
            >>>>>>>>>>> .ConnectionStri ng = sPath
            >>>>>>>>>>> .Open() --what happens here when the maximum pool size
            >>>>>>>>>>>ha s been reached ?
            >>>>>>>>>>>>
            >>>>>>>>>>>Than ks
            >>>>>>>>>>>>
            >>>>>>>>>>>>
            >>>>>>>>>>>
            >>>>>>>>>>>
            >>>>>>>>>>
            >>>>>>>>>>
            >>>>>>>>>
            >>>>>>>>>
            >>>>>>>>
            >>>>>>>>
            >>>>>>>
            >>>>>>>
            >>>>>>
            >>>>>>
            >>>>>
            >>>>>
            >>>>
            >>>>
            >>>
            >>>
            >>
            >>
            >
            >

            Comment

            • Paul Clement

              #21
              Re: Connection pooling question

              On Wed, 18 Apr 2007 09:21:38 -0500, "fniles" <fniles@pfmail. comwrote:

              ¤ I notice when the application uses an Access db on my machine (where no
              ¤ other application access that database) my application does not reach the
              ¤ maximum pool connection as fast as when I use an Access db on our server
              ¤ (where many other applications access that database).
              ¤ Is this because even though my application say has maximum of 100
              ¤ connections, because other applications access the same database, there may
              ¤ not be connection available ?

              I'm not sure how you're monitoring the application pool but there shouldn't be any difference. The
              application pool for the app on your machine will not reflect usage from clients on other machines.
              If you're monitoring the Jet Roster, then that's a bit different since it will reflect all the
              connections to the database.


              Paul
              ~~~~
              Microsoft MVP (Visual Basic)

              Comment

              Working...