473,473 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Connection pooling question

I am using VS2003 and connecting to MS Access database.
When using a connection pooling (every time I open the OLEDBCONNECTION 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 ?

ConnectionDemoOLE = New OleDb.OleDbConnection
sPath = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sDBPath & ";OLE DB
Services=-1"
With ConnectionDemoOLE
.ConnectionString = sPath
.Open() --what happens here when the maximum pool size has been
reached ?

Thanks
Apr 16 '07 #1
20 3234
I don't think there are any system counters exposed by the JET provider 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 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

--
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" <fn****@pfmail.comwrote in message
news:ej**************@TK2MSFTNGP03.phx.gbl...
>I am using VS2003 and connecting to MS Access database.
When using a connection pooling (every time I open the OLEDBCONNECTION 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 ?

ConnectionDemoOLE = New OleDb.OleDbConnection
sPath = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sDBPath & ";OLE
DB
Services=-1"
With ConnectionDemoOLE
.ConnectionString = sPath
.Open() --what happens here when the maximum pool size has been
reached ?

Thanks


Apr 16 '07 #2
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 ?

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 ?
In my other posting I posted that sometimes I get "Unspecified 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 "Unspecified error" on the
Open method caused by the maximum pool size has been reached ?

Dim swError As StreamWriter
Dim sSub As String
Try
sSub = "1"
ConnectionOLE = New OleDb.OleDbConnection
OpenDBOLE = True
With ConnectionOLE
.ConnectionString = g_dbPath
sSub = "2"
.Open() --IF MAX POOL SIZE HAS BEEN REACHED, IT WILL GO
TO THE Catch section below ?
sSub = "3"
End With
Catch ex As Exception
swError = New StreamWriter(Application.StartupPath &
"\AQErrorLog" & Date.Now.ToString("MMddyy") & ".txt", True)
swError.Write(Now & " OpenDBOLE - error = " & ex.Message & "
sub = " & sSub & " g_dbPath = " & g_dbPath & vbCrLf)
swError.Close()
swError = Nothing
End Try

Thank you.

"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comwrote in message
news:u2****************@TK2MSFTNGP02.phx.gbl...
>I don't think there are any system counters exposed by the JET provider 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 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

--
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" <fn****@pfmail.comwrote in message
news:ej**************@TK2MSFTNGP03.phx.gbl...
>>I am using VS2003 and connecting to MS Access database.
When using a connection pooling (every time I open the OLEDBCONNECTION 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 ?

ConnectionDemoOLE = New OleDb.OleDbConnection
sPath = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sDBPath & ";OLE
DB
Services=-1"
With ConnectionDemoOLE
.ConnectionString = sPath
.Open() --what happens here when the maximum pool size has been
reached ?

Thanks



Apr 16 '07 #3
See >>>>>

--
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" <fn****@pfmail.comwrote in message
news:%2****************@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 ?
>>>>Nope.
>
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 "Unspecified 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 "Unspecified error"
on the Open method caused by the maximum pool size has been reached ?
>>>"Unspecified" errors generally means you don't have a Try/Catch block
to trap the specific exception. In Access/JET, yes it might mean the
pool is full or the database is corrupt, or almost anything else.
>
Dim swError As StreamWriter
Dim sSub As String
Try
sSub = "1"
ConnectionOLE = New OleDb.OleDbConnection
OpenDBOLE = True
With ConnectionOLE
.ConnectionString = 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(Application.StartupPath &
"\AQErrorLog" & Date.Now.ToString("MMddyy") & ".txt", True)
swError.Write(Now & " OpenDBOLE - error = " & ex.Message &
" sub = " & sSub & " g_dbPath = " & g_dbPath & vbCrLf)
swError.Close()
swError = Nothing
End Try

Thank you.

"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comwrote in message
news:u2****************@TK2MSFTNGP02.phx.gbl...
>>I don't think there are any system counters exposed by the JET provider 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 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

--
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" <fn****@pfmail.comwrote in message
news:ej**************@TK2MSFTNGP03.phx.gbl...
>>>I am using VS2003 and connecting to MS Access database.
When using a connection pooling (every time I open the OLEDBCONNECTION 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 ?

ConnectionDemoOLE = New OleDb.OleDbConnection
sPath = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sDBPath &
";OLE DB
Services=-1"
With ConnectionDemoOLE
.ConnectionString = sPath
.Open() --what happens here when the maximum pool size has been
reached ?

Thanks




Apr 16 '07 #4
Bill,

Although I agree with your conclusion.

Using Access over the Web means to have an ASP or an ASPX application which
runs on a Server. (Mostly the same as the webapplication runs on). In fact
there is one user (ASPUSER), which uses the ASP or ASPX application.

What is not possible is using Access over the web by using by instance its
IP address as it is by real databaseservers is possible (I thought that this
possibility is removed in SQLExpress) .

I assume that you understand that there is not any connection pooling
problem at all. Probably you know this, however to be complete for others.
Concurrency problems stay because the webprogram is sending data to its
clients, which works in a 3 tier way using the browsers as non intelligent
workstations as we called them in past (VT100 etc).

Cor
"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comschreef in bericht
news:u2****************@TK2MSFTNGP02.phx.gbl...
>I don't think there are any system counters exposed by the JET provider 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 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

--
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" <fn****@pfmail.comwrote in message
news:ej**************@TK2MSFTNGP03.phx.gbl...
>>I am using VS2003 and connecting to MS Access database.
When using a connection pooling (every time I open the OLEDBCONNECTION 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 ?

ConnectionDemoOLE = New OleDb.OleDbConnection
sPath = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sDBPath & ";OLE
DB
Services=-1"
With ConnectionDemoOLE
.ConnectionString = sPath
.Open() --what happens here when the maximum pool size has been
reached ?

Thanks



Apr 17 '07 #5
Thank you.
I do use try/catch, but I get the "Unspecified 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.OleDbConnection
OpenDBOLE = True
With ConnectionOLE
.ConnectionString = 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.

"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comwrote in message
news:Ol****************@TK2MSFTNGP02.phx.gbl...
See >>>>>

--
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" <fn****@pfmail.comwrote in message
news:%2****************@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 ?
>>>>>Nope.
>>
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 "Unspecified 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 "Unspecified error"
on the Open method caused by the maximum pool size has been reached ?
>>>>"Unspecified" errors generally means you don't have a Try/Catch block
to trap the specific exception. In Access/JET, yes it might mean the
pool is full or the database is corrupt, or almost anything else.

>>
Dim swError As StreamWriter
Dim sSub As String
Try
sSub = "1"
ConnectionOLE = New OleDb.OleDbConnection
OpenDBOLE = True
With ConnectionOLE
.ConnectionString = 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(Application.StartupPath &
"\AQErrorLog" & Date.Now.ToString("MMddyy") & ".txt", True)
swError.Write(Now & " OpenDBOLE - error = " & ex.Message &
" sub = " & sSub & " g_dbPath = " & g_dbPath & vbCrLf)
swError.Close()
swError = Nothing
End Try

Thank you.

"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comwrote in message
news:u2****************@TK2MSFTNGP02.phx.gbl...
>>>I don't think there are any system counters exposed by the JET provider
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 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

--
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" <fn****@pfmail.comwrote in message
news:ej**************@TK2MSFTNGP03.phx.gbl...
I am using VS2003 and connecting to MS Access database.
When using a connection pooling (every time I open the OLEDBCONNECTION
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
?

ConnectionDemoOLE = New OleDb.OleDbConnection
sPath = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sDBPath &
";OLE DB
Services=-1"
With ConnectionDemoOLE
.ConnectionString = sPath
.Open() --what happens here when the maximum pool size has been
reached ?

Thanks




Apr 17 '07 #6
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 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
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" <fn****@pfmail.comwrote in message
news:OU**************@TK2MSFTNGP06.phx.gbl...
Thank you.
I do use try/catch, but I get the "Unspecified 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.OleDbConnection
OpenDBOLE = True
With ConnectionOLE
.ConnectionString = 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.

"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comwrote in message
news:Ol****************@TK2MSFTNGP02.phx.gbl...
>See >>>>>

--
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" <fn****@pfmail.comwrote in message
news:%2****************@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 ?
>>>>>>Nope.
>>>
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 "Unspecified 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
"Unspecified error" on the Open method caused by the maximum pool size
has been reached ?
>>>>>"Unspecified" errors generally means you don't have a Try/Catch block
>to trap the specific exception. In Access/JET, yes it might mean the
>pool is full or the database is corrupt, or almost anything else.

>>>
Dim swError As StreamWriter
Dim sSub As String
Try
sSub = "1"
ConnectionOLE = New OleDb.OleDbConnection
OpenDBOLE = True
With ConnectionOLE
.ConnectionString = 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(Application.StartupPath &
"\AQErrorLog" & Date.Now.ToString("MMddyy") & ".txt", True)
swError.Write(Now & " OpenDBOLE - error = " & ex.Message
& " sub = " & sSub & " g_dbPath = " & g_dbPath & vbCrLf)
swError.Close()
swError = Nothing
End Try

Thank you.

"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comwrote in message
news:u2****************@TK2MSFTNGP02.phx.gbl.. .
I don't think there are any system counters exposed by the JET provider
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 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

--
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" <fn****@pfmail.comwrote in message
news:ej**************@TK2MSFTNGP03.phx.gbl...
>I am using VS2003 and connecting to MS Access database.
When using a connection pooling (every time I open the OLEDBCONNECTION
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
?
>
ConnectionDemoOLE = New OleDb.OleDbConnection
sPath = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sDBPath &
";OLE DB
Services=-1"
With ConnectionDemoOLE
.ConnectionString = sPath
.Open() --what happens here when the maximum pool size has been
reached ?
>
Thanks
>
>




Apr 17 '07 #7
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.OleDbCommand
Dim da As OleDb.OleDbDataAdapter
Dim ds As DataSet
Dim ConnectionDemoOLE As OleDb.OleDbConnection
With cmd
bDBSuccess = OpenDBDemoOLE(ConnectionDemoOLE)
If bDBSuccess Then
.Connection = ConnectionDemoOLE
.CommandText = sql
Try
da = New OleDb.OleDbDataAdapter
ds = New DataSet
da.SelectCommand = cmd
da.Fill(ds)
CloseConDemoOLE(ConnectionDemoOLE)
Catch ex As Exception
end try
Sub CloseConDemoOLE(ByRef ConnectionDemoOLE As OleDb.OleDbConnection)
If Not ConnectionDemoOLE Is Nothing Then
ConnectionDemoOLE.Close()
ConnectionDemoOLE = Nothing
End If
End Sub

Function OpenDBDemoOLE(ByRef ConnectionDemoOLE As OleDb.OleDbConnection)
As Boolean
Try
ConnectionDemoOLE = New OleDb.OleDbConnection
OpenDBDemoOLE = True
With ConnectionDemoOLE
.ConnectionString = g_dbPathDemo
.Open()
If .State = ConnectionState.Closed Then
CloseConDemoOLE(ConnectionDemoOLE)
OpenDBDemoOLE = False
End If
End With
Catch ex As Exception
end try

"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comwrote in message
news:Or**************@TK2MSFTNGP04.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 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
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" <fn****@pfmail.comwrote in message
news:OU**************@TK2MSFTNGP06.phx.gbl...
>Thank you.
I do use try/catch, but I get the "Unspecified 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.OleDbConnection
OpenDBOLE = True
With ConnectionOLE
.ConnectionString = 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.

"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comwrote in message
news:Ol****************@TK2MSFTNGP02.phx.gbl...
>>See >>>>>

--
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" <fn****@pfmail.comwrote in message
news:%2****************@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 ?

>>>Nope.
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 "Unspecified 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
"Unspecified error" on the Open method caused by the maximum pool size
has been reached ?

>>"Unspecified" errors generally means you don't have a Try/Catch
>>block to trap the specific exception. In Access/JET, yes it might
>>mean the pool is full or the database is corrupt, or almost anything
>>else.

Dim swError As StreamWriter
Dim sSub As String
Try
sSub = "1"
ConnectionOLE = New OleDb.OleDbConnection
OpenDBOLE = True
With ConnectionOLE
.ConnectionString = 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(Application.StartupPath &
"\AQErrorLog" & Date.Now.ToString("MMddyy") & ".txt", True)
swError.Write(Now & " OpenDBOLE - error = " & ex.Message
& " sub = " & sSub & " g_dbPath = " & g_dbPath & vbCrLf)
swError.Close()
swError = Nothing
End Try

Thank you.

"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comwrote in message
news:u2****************@TK2MSFTNGP02.phx.gbl. ..
>I don't think there are any system counters exposed by the JET provider
>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 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
>
--
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" <fn****@pfmail.comwrote in message
news:ej**************@TK2MSFTNGP03.phx.gbl.. .
>>I am using VS2003 and connecting to MS Access database.
>When using a connection pooling (every time I open the
>OLEDBCONNECTION 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 ?
>>
>ConnectionDemoOLE = New OleDb.OleDbConnection
>sPath = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sDBPath &
>";OLE DB
>Services=-1"
>With ConnectionDemoOLE
> .ConnectionString = sPath
> .Open() --what happens here when the maximum pool size has been
>reached ?
>>
>Thanks
>>
>>
>
>




Apr 17 '07 #8
CP::Connection 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" <fn****@pfmail.comwrote in message
news:eg**************@TK2MSFTNGP02.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.OleDbCommand
Dim da As OleDb.OleDbDataAdapter
Dim ds As DataSet
Dim ConnectionDemoOLE As OleDb.OleDbConnection
With cmd
bDBSuccess = OpenDBDemoOLE(ConnectionDemoOLE)
If bDBSuccess Then
.Connection = ConnectionDemoOLE
.CommandText = sql
Try
da = New OleDb.OleDbDataAdapter
ds = New DataSet
da.SelectCommand = cmd
da.Fill(ds)
CloseConDemoOLE(ConnectionDemoOLE)
Catch ex As Exception
end try
Sub CloseConDemoOLE(ByRef ConnectionDemoOLE As OleDb.OleDbConnection)
If Not ConnectionDemoOLE Is Nothing Then
ConnectionDemoOLE.Close()
ConnectionDemoOLE = Nothing
End If
End Sub

Function OpenDBDemoOLE(ByRef ConnectionDemoOLE As
OleDb.OleDbConnection) As Boolean
Try
ConnectionDemoOLE = New OleDb.OleDbConnection
OpenDBDemoOLE = True
With ConnectionDemoOLE
.ConnectionString = g_dbPathDemo
.Open()
If .State = ConnectionState.Closed Then
CloseConDemoOLE(ConnectionDemoOLE)
OpenDBDemoOLE = False
End If
End With
Catch ex As Exception
end try

"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comwrote in message
news:Or**************@TK2MSFTNGP04.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 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
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" <fn****@pfmail.comwrote in message
news:OU**************@TK2MSFTNGP06.phx.gbl...
>>Thank you.
I do use try/catch, but I get the "Unspecified 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.OleDbConnection
OpenDBOLE = True
With ConnectionOLE
.ConnectionString = 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.

"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comwrote in message
news:Ol****************@TK2MSFTNGP02.phx.gbl.. .
See >>>>>

--
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" <fn****@pfmail.comwrote in message
news:%2****************@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 ?

>>>>Nope.

>
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 "Unspecified 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
"Unspecified error" on the Open method caused by the maximum pool size
has been reached ?

>>>"Unspecified" errors generally means you don't have a Try/Catch
>>>block to trap the specific exception. In Access/JET, yes it might
>>>mean the pool is full or the database is corrupt, or almost
>>>anything else.
>
Dim swError As StreamWriter
Dim sSub As String
Try
sSub = "1"
ConnectionOLE = New OleDb.OleDbConnection
OpenDBOLE = True
With ConnectionOLE
.ConnectionString = 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(Application.StartupPath &
"\AQErrorLog" & Date.Now.ToString("MMddyy") & ".txt", True)
swError.Write(Now & " OpenDBOLE - error = " &
ex.Message & " sub = " & sSub & " g_dbPath = " & g_dbPath & vbCrLf)
swError.Close()
swError = Nothing
End Try
>
Thank you.
>
>
>
"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comwrote in
message news:u2****************@TK2MSFTNGP02.phx.gbl...
>>I don't think there are any system counters exposed by the JET
>>provider 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 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
>>
>--
>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" <fn****@pfmail.comwrote in message
>news:ej**************@TK2MSFTNGP03.phx.gbl. ..
>>>I am using VS2003 and connecting to MS Access database.
>>When using a connection pooling (every time I open the
>>OLEDBCONNECTION 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 ?
>>>
>>ConnectionDemoOLE = New OleDb.OleDbConnection
>>sPath = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sDBPath &
>>";OLE DB
>>Services=-1"
>>With ConnectionDemoOLE
>> .ConnectionString = sPath
>> .Open() --what happens here when the maximum pool size has
>>been reached ?
>>>
>>Thanks
>>>
>>>
>>
>>
>
>




Apr 18 '07 #9
On Mon, 16 Apr 2007 16:18:56 -0500, "fniles" <fn****@pfmail.comwrote:

¤ I am using VS2003 and connecting to MS Access database.
¤ When using a connection pooling (every time I open the OLEDBCONNECTION 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 ?
¤
¤ ConnectionDemoOLE = New OleDb.OleDbConnection
¤ sPath = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sDBPath & ";OLE DB
¤ Services=-1"
¤ With ConnectionDemoOLE
¤ .ConnectionString = sPath
¤ .Open() --what happens here when the maximum pool size has been
¤ reached ?

While connection pooling is supported in Jet, it's really of little value and there isn't really any
point in attempting to monitor it. But to answer your prior question, it's enabled by default and
the connection pools are maintained on each client that opens the database because that is where the
database engine in running.

If instead you want to monitor the users in your database there are tools to do this:

How to determine who is logged on to a database by using Microsoft Jet UserRoster in Access 2000
http://support.microsoft.com/default...b;EN-US;198755
Paul
~~~~
Microsoft MVP (Visual Basic)
Apr 18 '07 #10
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.OleDbCommand
Dim da As OleDb.OleDbDataAdapter
Dim ds As DataSet
Dim ConnectionDemoOLE As OleDb.OleDbConnection
With cmd
'----DO NOT NEED THIS CODE ----- bDBSuccess =
OpenDBDemoOLE(ConnectionDemoOLE) ------'
'----If bDBSuccess Then
.Connection = ConnectionDemoOLE '????
.CommandText = sql
Try
da = New OleDb.OleDbDataAdapter
ds = New DataSet
da.SelectCommand = cmd
da.Fill(ds)
CloseConDemoOLE(ConnectionDemoOLE)
Catch ex As Exception
end try

Thank you.

"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comwrote in message
news:ul**************@TK2MSFTNGP05.phx.gbl...
CP::Connection 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" <fn****@pfmail.comwrote in message
news:eg**************@TK2MSFTNGP02.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.OleDbCommand
Dim da As OleDb.OleDbDataAdapter
Dim ds As DataSet
Dim ConnectionDemoOLE As OleDb.OleDbConnection
With cmd
bDBSuccess = OpenDBDemoOLE(ConnectionDemoOLE)
If bDBSuccess Then
.Connection = ConnectionDemoOLE
.CommandText = sql
Try
da = New OleDb.OleDbDataAdapter
ds = New DataSet
da.SelectCommand = cmd
da.Fill(ds)
CloseConDemoOLE(ConnectionDemoOLE)
Catch ex As Exception
end try
Sub CloseConDemoOLE(ByRef ConnectionDemoOLE As OleDb.OleDbConnection)
If Not ConnectionDemoOLE Is Nothing Then
ConnectionDemoOLE.Close()
ConnectionDemoOLE = Nothing
End If
End Sub

Function OpenDBDemoOLE(ByRef ConnectionDemoOLE As
OleDb.OleDbConnection) As Boolean
Try
ConnectionDemoOLE = New OleDb.OleDbConnection
OpenDBDemoOLE = True
With ConnectionDemoOLE
.ConnectionString = g_dbPathDemo
.Open()
If .State = ConnectionState.Closed Then
CloseConDemoOLE(ConnectionDemoOLE)
OpenDBDemoOLE = False
End If
End With
Catch ex As Exception
end try

"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comwrote in message
news:Or**************@TK2MSFTNGP04.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 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
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" <fn****@pfmail.comwrote in message
news:OU**************@TK2MSFTNGP06.phx.gbl...
Thank you.
I do use try/catch, but I get the "Unspecified 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.OleDbConnection
OpenDBOLE = True
With ConnectionOLE
.ConnectionString = 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.

"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comwrote in message
news:Ol****************@TK2MSFTNGP02.phx.gbl. ..
See >>>>>
>
--
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" <fn****@pfmail.comwrote in message
news:%2****************@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 ?
>
>>>>>Nope.
>
>>
>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 "Unspecified 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
>"Unspecified error" on the Open method caused by the maximum pool
>size has been reached ?
>
>>>>"Unspecified" errors generally means you don't have a Try/Catch
>>>>block to trap the specific exception. In Access/JET, yes it might
>>>>mean the pool is full or the database is corrupt, or almost
>>>>anything else.
>
>
>>
> Dim swError As StreamWriter
> Dim sSub As String
> Try
> sSub = "1"
> ConnectionOLE = New OleDb.OleDbConnection
> OpenDBOLE = True
> With ConnectionOLE
> .ConnectionString = 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(Application.StartupPath &
>"\AQErrorLog" & Date.Now.ToString("MMddyy") & ".txt", True)
> swError.Write(Now & " OpenDBOLE - error = " &
>ex.Message & " sub = " & sSub & " g_dbPath = " & g_dbPath & vbCrLf)
> swError.Close()
> swError = Nothing
> End Try
>>
>Thank you.
>>
>>
>>
>"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comwrote in
>message news:u2****************@TK2MSFTNGP02.phx.gbl...
>>>I don't think there are any system counters exposed by the JET
>>>provider 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 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
>>>
>>--
>>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" <fn****@pfmail.comwrote in message
>>news:ej**************@TK2MSFTNGP03.phx.gbl.. .
>>>>I am using VS2003 and connecting to MS Access database.
>>>When using a connection pooling (every time I open the
>>>OLEDBCONNECTION 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 ?
>>>>
>>>ConnectionDemoOLE = New OleDb.OleDbConnection
>>>sPath = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sDBPath &
>>>";OLE DB
>>>Services=-1"
>>>With ConnectionDemoOLE
>>> .ConnectionString = sPath
>>> .Open() --what happens here when the maximum pool size has
>>>been reached ?
>>>>
>>>Thanks
>>>>
>>>>
>>>
>>>
>>
>>
>
>




Apr 18 '07 #11
I have a question.
If for example application A and B uses the same database (either Access or
SQL Server).
Will the maximum connection pooling apply per application ? In other words,
if maximum connection pooling is 100, application A uses 10 connetions, will
application B has 90 or 100 connections left ?

Thank you.

"Paul Clement" <Us***********************@swspectrum.comwrote in message
news:gk********************************@4ax.com...
On Mon, 16 Apr 2007 16:18:56 -0500, "fniles" <fn****@pfmail.comwrote:

¤ I am using VS2003 and connecting to MS Access database.
¤ When using a connection pooling (every time I open the OLEDBCONNECTION 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 ?
¤
¤ ConnectionDemoOLE = New OleDb.OleDbConnection
¤ sPath = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sDBPath &
";OLE DB
¤ Services=-1"
¤ With ConnectionDemoOLE
¤ .ConnectionString = sPath
¤ .Open() --what happens here when the maximum pool size has been
¤ reached ?

While connection pooling is supported in Jet, it's really of little value
and there isn't really any
point in attempting to monitor it. But to answer your prior question, it's
enabled by default and
the connection pools are maintained on each client that opens the database
because that is where the
database engine in running.

If instead you want to monitor the users in your database there are tools
to do this:

How to determine who is logged on to a database by using Microsoft Jet
UserRoster in Access 2000
http://support.microsoft.com/default...b;EN-US;198755
Paul
~~~~
Microsoft MVP (Visual Basic)

Apr 18 '07 #12
On Wed, 18 Apr 2007 08:37:33 -0500, "fniles" <fn****@pfmail.comwrote:

¤ I have a question.
¤ If for example application A and B uses the same database (either Access or
¤ SQL Server).
¤ Will the maximum connection pooling apply per application ? In other words,
¤ if maximum connection pooling is 100, application A uses 10 connetions, will
¤ application B has 90 or 100 connections left ?

Connection pools are create per process (or app pool) and per unique connection string. So unless
application A and application B are in the same app pool (such as a web appl) they will each have
their own connection pool.
Paul
~~~~
Microsoft MVP (Visual Basic)
Apr 18 '07 #13
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 ?

Thanks.

"Paul Clement" <Us***********************@swspectrum.comwrote in message
news:79********************************@4ax.com...
On Wed, 18 Apr 2007 08:37:33 -0500, "fniles" <fn****@pfmail.comwrote:

¤ I have a question.
¤ If for example application A and B uses the same database (either Access
or
¤ SQL Server).
¤ Will the maximum connection pooling apply per application ? In other
words,
¤ if maximum connection pooling is 100, application A uses 10 connetions,
will
¤ application B has 90 or 100 connections left ?

Connection pools are create per process (or app pool) and per unique
connection string. So unless
application A and application B are in the same app pool (such as a web
appl) they will each have
their own connection pool.
Paul
~~~~
Microsoft MVP (Visual Basic)

Apr 18 '07 #14
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_sConnectionString 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_sConnectionString), and close it after populating a
DataSet.
Is this correct ?

Thank you.

"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comwrote in message
news:ul**************@TK2MSFTNGP05.phx.gbl...
CP::Connection 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" <fn****@pfmail.comwrote in message
news:eg**************@TK2MSFTNGP02.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.OleDbCommand
Dim da As OleDb.OleDbDataAdapter
Dim ds As DataSet
Dim ConnectionDemoOLE As OleDb.OleDbConnection
With cmd
bDBSuccess = OpenDBDemoOLE(ConnectionDemoOLE)
If bDBSuccess Then
.Connection = ConnectionDemoOLE
.CommandText = sql
Try
da = New OleDb.OleDbDataAdapter
ds = New DataSet
da.SelectCommand = cmd
da.Fill(ds)
CloseConDemoOLE(ConnectionDemoOLE)
Catch ex As Exception
end try
Sub CloseConDemoOLE(ByRef ConnectionDemoOLE As OleDb.OleDbConnection)
If Not ConnectionDemoOLE Is Nothing Then
ConnectionDemoOLE.Close()
ConnectionDemoOLE = Nothing
End If
End Sub

Function OpenDBDemoOLE(ByRef ConnectionDemoOLE As
OleDb.OleDbConnection) As Boolean
Try
ConnectionDemoOLE = New OleDb.OleDbConnection
OpenDBDemoOLE = True
With ConnectionDemoOLE
.ConnectionString = g_dbPathDemo
.Open()
If .State = ConnectionState.Closed Then
CloseConDemoOLE(ConnectionDemoOLE)
OpenDBDemoOLE = False
End If
End With
Catch ex As Exception
end try

"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comwrote in message
news:Or**************@TK2MSFTNGP04.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 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
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" <fn****@pfmail.comwrote in message
news:OU**************@TK2MSFTNGP06.phx.gbl...
Thank you.
I do use try/catch, but I get the "Unspecified 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.OleDbConnection
OpenDBOLE = True
With ConnectionOLE
.ConnectionString = 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.

"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comwrote in message
news:Ol****************@TK2MSFTNGP02.phx.gbl. ..
See >>>>>
>
--
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" <fn****@pfmail.comwrote in message
news:%2****************@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 ?
>
>>>>>Nope.
>
>>
>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 "Unspecified 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
>"Unspecified error" on the Open method caused by the maximum pool
>size has been reached ?
>
>>>>"Unspecified" errors generally means you don't have a Try/Catch
>>>>block to trap the specific exception. In Access/JET, yes it might
>>>>mean the pool is full or the database is corrupt, or almost
>>>>anything else.
>
>
>>
> Dim swError As StreamWriter
> Dim sSub As String
> Try
> sSub = "1"
> ConnectionOLE = New OleDb.OleDbConnection
> OpenDBOLE = True
> With ConnectionOLE
> .ConnectionString = 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(Application.StartupPath &
>"\AQErrorLog" & Date.Now.ToString("MMddyy") & ".txt", True)
> swError.Write(Now & " OpenDBOLE - error = " &
>ex.Message & " sub = " & sSub & " g_dbPath = " & g_dbPath & vbCrLf)
> swError.Close()
> swError = Nothing
> End Try
>>
>Thank you.
>>
>>
>>
>"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comwrote in
>message news:u2****************@TK2MSFTNGP02.phx.gbl...
>>>I don't think there are any system counters exposed by the JET
>>>provider 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 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
>>>
>>--
>>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" <fn****@pfmail.comwrote in message
>>news:ej**************@TK2MSFTNGP03.phx.gbl.. .
>>>>I am using VS2003 and connecting to MS Access database.
>>>When using a connection pooling (every time I open the
>>>OLEDBCONNECTION 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 ?
>>>>
>>>ConnectionDemoOLE = New OleDb.OleDbConnection
>>>sPath = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sDBPath &
>>>";OLE DB
>>>Services=-1"
>>>With ConnectionDemoOLE
>>> .ConnectionString = sPath
>>> .Open() --what happens here when the maximum pool size has
>>>been reached ?
>>>>
>>>Thanks
>>>>
>>>>
>>>
>>>
>>
>>
>
>




Apr 18 '07 #15
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" <fn****@pfmail.comschreef in bericht
news:e$*************@TK2MSFTNGP05.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_sConnectionString 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_sConnectionString), and close it after populating a
DataSet.
Is this correct ?

Thank you.

"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comwrote in message
news:ul**************@TK2MSFTNGP05.phx.gbl...
>CP::Connection 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" <fn****@pfmail.comwrote in message
news:eg**************@TK2MSFTNGP02.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.OleDbCommand
Dim da As OleDb.OleDbDataAdapter
Dim ds As DataSet
Dim ConnectionDemoOLE As OleDb.OleDbConnection
With cmd
bDBSuccess = OpenDBDemoOLE(ConnectionDemoOLE)
If bDBSuccess Then
.Connection = ConnectionDemoOLE
.CommandText = sql
Try
da = New OleDb.OleDbDataAdapter
ds = New DataSet
da.SelectCommand = cmd
da.Fill(ds)
CloseConDemoOLE(ConnectionDemoOLE)
Catch ex As Exception
end try
Sub CloseConDemoOLE(ByRef ConnectionDemoOLE As OleDb.OleDbConnection)
If Not ConnectionDemoOLE Is Nothing Then
ConnectionDemoOLE.Close()
ConnectionDemoOLE = Nothing
End If
End Sub

Function OpenDBDemoOLE(ByRef ConnectionDemoOLE As
OleDb.OleDbConnection) As Boolean
Try
ConnectionDemoOLE = New OleDb.OleDbConnection
OpenDBDemoOLE = True
With ConnectionDemoOLE
.ConnectionString = g_dbPathDemo
.Open()
If .State = ConnectionState.Closed Then
CloseConDemoOLE(ConnectionDemoOLE)
OpenDBDemoOLE = False
End If
End With
Catch ex As Exception
end try

"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comwrote in message
news:Or**************@TK2MSFTNGP04.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
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
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" <fn****@pfmail.comwrote in message
news:OU**************@TK2MSFTNGP06.phx.gbl...
Thank you.
I do use try/catch, but I get the "Unspecified 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.OleDbConnection
OpenDBOLE = True
With ConnectionOLE
.ConnectionString = 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.
>
"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comwrote in
message news:Ol****************@TK2MSFTNGP02.phx.gbl...
>See >>>>>
>>
>--
>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" <fn****@pfmail.comwrote in message
>news:%2****************@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 ?
>>
>>>>>>Nope.
>>
>>>
>>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 "Unspecified
>>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 "Unspecified error" on the Open method caused by the
>>maximum pool size has been reached ?
>>
>>>>>"Unspecified" errors generally means you don't have a Try/Catch
>>>>>block to trap the specific exception. In Access/JET, yes it might
>>>>>mean the pool is full or the database is corrupt, or almost
>>>>>anything else.
>>
>>
>>>
>> Dim swError As StreamWriter
>> Dim sSub As String
>> Try
>> sSub = "1"
>> ConnectionOLE = New OleDb.OleDbConnection
>> OpenDBOLE = True
>> With ConnectionOLE
>> .ConnectionString = 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(Application.StartupPath &
>>"\AQErrorLog" & Date.Now.ToString("MMddyy") & ".txt", True)
>> swError.Write(Now & " OpenDBOLE - error = " &
>>ex.Message & " sub = " & sSub & " g_dbPath = " & g_dbPath & vbCrLf)
>> swError.Close()
>> swError = Nothing
>> End Try
>>>
>>Thank you.
>>>
>>>
>>>
>>"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comwrote in
>>message news:u2****************@TK2MSFTNGP02.phx.gbl...
>>>>I don't think there are any system counters exposed by the JET
>>>>provider 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 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
>>>>
>>>--
>>>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" <fn****@pfmail.comwrote in message
>>>news:ej**************@TK2MSFTNGP03.phx.gbl. ..
>>>>>I am using VS2003 and connecting to MS Access database.
>>>>When using a connection pooling (every time I open the
>>>>OLEDBCONNECTION 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 ?
>>>>>
>>>>ConnectionDemoOLE = New OleDb.OleDbConnection
>>>>sPath = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sDBPath
>>>>& ";OLE DB
>>>>Services=-1"
>>>>With ConnectionDemoOLE
>>>> .ConnectionString = sPath
>>>> .Open() --what happens here when the maximum pool size has
>>>>been reached ?
>>>>>
>>>>Thanks
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>




Apr 18 '07 #16
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
ConnectionString 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" <fn****@pfmail.comwrote in message
news:%2****************@TK2MSFTNGP04.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.OleDbCommand
Dim da As OleDb.OleDbDataAdapter
Dim ds As DataSet
Dim ConnectionDemoOLE As OleDb.OleDbConnection
With cmd
'----DO NOT NEED THIS CODE ----- bDBSuccess =
OpenDBDemoOLE(ConnectionDemoOLE) ------'
'----If bDBSuccess Then
.Connection = ConnectionDemoOLE '????
.CommandText = sql
Try
da = New OleDb.OleDbDataAdapter
ds = New DataSet
da.SelectCommand = cmd
da.Fill(ds)
CloseConDemoOLE(ConnectionDemoOLE)
Catch ex As Exception
end try

Thank you.

"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comwrote in message
news:ul**************@TK2MSFTNGP05.phx.gbl...
>CP::Connection 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" <fn****@pfmail.comwrote in message
news:eg**************@TK2MSFTNGP02.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.OleDbCommand
Dim da As OleDb.OleDbDataAdapter
Dim ds As DataSet
Dim ConnectionDemoOLE As OleDb.OleDbConnection
With cmd
bDBSuccess = OpenDBDemoOLE(ConnectionDemoOLE)
If bDBSuccess Then
.Connection = ConnectionDemoOLE
.CommandText = sql
Try
da = New OleDb.OleDbDataAdapter
ds = New DataSet
da.SelectCommand = cmd
da.Fill(ds)
CloseConDemoOLE(ConnectionDemoOLE)
Catch ex As Exception
end try
Sub CloseConDemoOLE(ByRef ConnectionDemoOLE As OleDb.OleDbConnection)
If Not ConnectionDemoOLE Is Nothing Then
ConnectionDemoOLE.Close()
ConnectionDemoOLE = Nothing
End If
End Sub

Function OpenDBDemoOLE(ByRef ConnectionDemoOLE As
OleDb.OleDbConnection) As Boolean
Try
ConnectionDemoOLE = New OleDb.OleDbConnection
OpenDBDemoOLE = True
With ConnectionDemoOLE
.ConnectionString = g_dbPathDemo
.Open()
If .State = ConnectionState.Closed Then
CloseConDemoOLE(ConnectionDemoOLE)
OpenDBDemoOLE = False
End If
End With
Catch ex As Exception
end try

"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comwrote in message
news:Or**************@TK2MSFTNGP04.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
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
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" <fn****@pfmail.comwrote in message
news:OU**************@TK2MSFTNGP06.phx.gbl...
Thank you.
I do use try/catch, but I get the "Unspecified 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.OleDbConnection
OpenDBOLE = True
With ConnectionOLE
.ConnectionString = 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.
>
"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comwrote in
message news:Ol****************@TK2MSFTNGP02.phx.gbl...
>See >>>>>
>>
>--
>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" <fn****@pfmail.comwrote in message
>news:%2****************@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 ?
>>
>>>>>>Nope.
>>
>>>
>>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 "Unspecified
>>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 "Unspecified error" on the Open method caused by the
>>maximum pool size has been reached ?
>>
>>>>>"Unspecified" errors generally means you don't have a Try/Catch
>>>>>block to trap the specific exception. In Access/JET, yes it might
>>>>>mean the pool is full or the database is corrupt, or almost
>>>>>anything else.
>>
>>
>>>
>> Dim swError As StreamWriter
>> Dim sSub As String
>> Try
>> sSub = "1"
>> ConnectionOLE = New OleDb.OleDbConnection
>> OpenDBOLE = True
>> With ConnectionOLE
>> .ConnectionString = 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(Application.StartupPath &
>>"\AQErrorLog" & Date.Now.ToString("MMddyy") & ".txt", True)
>> swError.Write(Now & " OpenDBOLE - error = " &
>>ex.Message & " sub = " & sSub & " g_dbPath = " & g_dbPath & vbCrLf)
>> swError.Close()
>> swError = Nothing
>> End Try
>>>
>>Thank you.
>>>
>>>
>>>
>>"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comwrote in
>>message news:u2****************@TK2MSFTNGP02.phx.gbl...
>>>>I don't think there are any system counters exposed by the JET
>>>>provider 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 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
>>>>
>>>--
>>>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" <fn****@pfmail.comwrote in message
>>>news:ej**************@TK2MSFTNGP03.phx.gbl. ..
>>>>>I am using VS2003 and connecting to MS Access database.
>>>>When using a connection pooling (every time I open the
>>>>OLEDBCONNECTION 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 ?
>>>>>
>>>>ConnectionDemoOLE = New OleDb.OleDbConnection
>>>>sPath = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sDBPath
>>>>& ";OLE DB
>>>>Services=-1"
>>>>With ConnectionDemoOLE
>>>> .ConnectionString = sPath
>>>> .Open() --what happens here when the maximum pool size has
>>>>been reached ?
>>>>>
>>>>Thanks
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>




Apr 18 '07 #17
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
ConnectionString 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@NoSpamAtAll_betav.comwrote in message
news:%2****************@TK2MSFTNGP03.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
ConnectionString 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" <fn****@pfmail.comwrote in message
news:%2****************@TK2MSFTNGP04.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.OleDbCommand
Dim da As OleDb.OleDbDataAdapter
Dim ds As DataSet
Dim ConnectionDemoOLE As OleDb.OleDbConnection
With cmd
'----DO NOT NEED THIS CODE ----- bDBSuccess =
OpenDBDemoOLE(ConnectionDemoOLE) ------'
'----If bDBSuccess Then
.Connection = ConnectionDemoOLE '????
.CommandText = sql
Try
da = New OleDb.OleDbDataAdapter
ds = New DataSet
da.SelectCommand = cmd
da.Fill(ds)
CloseConDemoOLE(ConnectionDemoOLE)
Catch ex As Exception
end try

Thank you.

"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comwrote in message
news:ul**************@TK2MSFTNGP05.phx.gbl...
>>CP::Connection 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" <fn****@pfmail.comwrote in message
news:eg**************@TK2MSFTNGP02.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.OleDbCommand
Dim da As OleDb.OleDbDataAdapter
Dim ds As DataSet
Dim ConnectionDemoOLE As OleDb.OleDbConnection
With cmd
bDBSuccess = OpenDBDemoOLE(ConnectionDemoOLE)
If bDBSuccess Then
.Connection = ConnectionDemoOLE
.CommandText = sql
Try
da = New OleDb.OleDbDataAdapter
ds = New DataSet
da.SelectCommand = cmd
da.Fill(ds)
CloseConDemoOLE(ConnectionDemoOLE)
Catch ex As Exception
end try
Sub CloseConDemoOLE(ByRef ConnectionDemoOLE As
OleDb.OleDbConnection)
If Not ConnectionDemoOLE Is Nothing Then
ConnectionDemoOLE.Close()
ConnectionDemoOLE = Nothing
End If
End Sub

Function OpenDBDemoOLE(ByRef ConnectionDemoOLE As
OleDb.OleDbConnection) As Boolean
Try
ConnectionDemoOLE = New OleDb.OleDbConnection
OpenDBDemoOLE = True
With ConnectionDemoOLE
.ConnectionString = g_dbPathDemo
.Open()
If .State = ConnectionState.Closed Then
CloseConDemoOLE(ConnectionDemoOLE)
OpenDBDemoOLE = False
End If
End With
Catch ex As Exception
end try

"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comwrote in message
news:Or**************@TK2MSFTNGP04.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
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
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" <fn****@pfmail.comwrote in message
news:OU**************@TK2MSFTNGP06.phx.gbl.. .
>Thank you.
>I do use try/catch, but I get the "Unspecified 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.OleDbConnection
> OpenDBOLE = True
> With ConnectionOLE
> .ConnectionString = 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.
>>
>"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comwrote in
>message news:Ol****************@TK2MSFTNGP02.phx.gbl...
>>See >>>>>
>>>
>>--
>>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" <fn****@pfmail.comwrote in message
>>news:%2****************@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 ?
>>>
>>>>>>>Nope.
>>>
>>>>
>>>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 "Unspecified
>>>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 "Unspecified error" on the Open method caused by the
>>>maximum pool size has been reached ?
>>>
>>>>>>"Unspecified" errors generally means you don't have a Try/Catch
>>>>>>block to trap the specific exception. In Access/JET, yes it
>>>>>>might mean the pool is full or the database is corrupt, or
>>>>>>almost anything else.
>>>
>>>
>>>>
>>> Dim swError As StreamWriter
>>> Dim sSub As String
>>> Try
>>> sSub = "1"
>>> ConnectionOLE = New OleDb.OleDbConnection
>>> OpenDBOLE = True
>>> With ConnectionOLE
>>> .ConnectionString = 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(Application.StartupPath &
>>>"\AQErrorLog" & Date.Now.ToString("MMddyy") & ".txt", True)
>>> swError.Write(Now & " OpenDBOLE - error = " &
>>>ex.Message & " sub = " & sSub & " g_dbPath = " & g_dbPath &
>>>vbCrLf)
>>> swError.Close()
>>> swError = Nothing
>>> End Try
>>>>
>>>Thank you.
>>>>
>>>>
>>>>
>>>"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comwrote in
>>>message news:u2****************@TK2MSFTNGP02.phx.gbl...
>>>>>I don't think there are any system counters exposed by the JET
>>>>>provider 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
>>>>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
>>>>>
>>>>--
>>>>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" <fn****@pfmail.comwrote in message
>>>>news:ej**************@TK2MSFTNGP03.phx.gbl ...
>>>>>>I am using VS2003 and connecting to MS Access database.
>>>>>When using a connection pooling (every time I open the
>>>>>OLEDBCONNECTION 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 ?
>>>>>>
>>>>>ConnectionDemoOLE = New OleDb.OleDbConnection
>>>>>sPath = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sDBPath
>>>>>& ";OLE DB
>>>>>Services=-1"
>>>>>With ConnectionDemoOLE
>>>>> .ConnectionString = sPath
>>>>> .Open() --what happens here when the maximum pool size has
>>>>>been reached ?
>>>>>>
>>>>>Thanks
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>




Apr 18 '07 #18
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
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" <fn****@pfmail.comwrote in message
news:OD**************@TK2MSFTNGP02.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
ConnectionString 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@NoSpamAtAll_betav.comwrote in message
news:%2****************@TK2MSFTNGP03.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
ConnectionString 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" <fn****@pfmail.comwrote in message
news:%2****************@TK2MSFTNGP04.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.OleDbCommand
Dim da As OleDb.OleDbDataAdapter
Dim ds As DataSet
Dim ConnectionDemoOLE As OleDb.OleDbConnection
With cmd
'----DO NOT NEED THIS CODE ----- bDBSuccess =
OpenDBDemoOLE(ConnectionDemoOLE) ------'
'----If bDBSuccess Then
.Connection = ConnectionDemoOLE '????
.CommandText = sql
Try
da = New OleDb.OleDbDataAdapter
ds = New DataSet
da.SelectCommand = cmd
da.Fill(ds)
CloseConDemoOLE(ConnectionDemoOLE)
Catch ex As Exception
end try

Thank you.

"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comwrote in message
news:ul**************@TK2MSFTNGP05.phx.gbl...
CP::Connection 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" <fn****@pfmail.comwrote in message
news:eg**************@TK2MSFTNGP02.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.OleDbCommand
Dim da As OleDb.OleDbDataAdapter
Dim ds As DataSet
Dim ConnectionDemoOLE As OleDb.OleDbConnection
With cmd
bDBSuccess = OpenDBDemoOLE(ConnectionDemoOLE)
If bDBSuccess Then
.Connection = ConnectionDemoOLE
.CommandText = sql
Try
da = New OleDb.OleDbDataAdapter
ds = New DataSet
da.SelectCommand = cmd
da.Fill(ds)
CloseConDemoOLE(ConnectionDemoOLE)
Catch ex As Exception
end try
Sub CloseConDemoOLE(ByRef ConnectionDemoOLE As
OleDb.OleDbConnection)
If Not ConnectionDemoOLE Is Nothing Then
ConnectionDemoOLE.Close()
ConnectionDemoOLE = Nothing
End If
End Sub
>
Function OpenDBDemoOLE(ByRef ConnectionDemoOLE As
OleDb.OleDbConnection) As Boolean
Try
ConnectionDemoOLE = New OleDb.OleDbConnection
OpenDBDemoOLE = True
With ConnectionDemoOLE
.ConnectionString = g_dbPathDemo
.Open()
If .State = ConnectionState.Closed Then
CloseConDemoOLE(ConnectionDemoOLE)
OpenDBDemoOLE = False
End If
End With
Catch ex As Exception
end try
>
"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comwrote in
message news:Or**************@TK2MSFTNGP04.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 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
>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" <fn****@pfmail.comwrote in message
>news:OU**************@TK2MSFTNGP06.phx.gbl. ..
>>Thank you.
>>I do use try/catch, but I get the "Unspecified 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.OleDbConnection
>> OpenDBOLE = True
>> With ConnectionOLE
>> .ConnectionString = 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.
>>>
>>"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comwrote in
>>message news:Ol****************@TK2MSFTNGP02.phx.gbl...
>>>See >>>>>
>>>>
>>>--
>>>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" <fn****@pfmail.comwrote in message
>>>news:%2****************@TK2MSFTNGP03.phx.gb l...
>>>>>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
>>>>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 "Unspecified
>>>>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 "Unspecified error" on the Open method caused by
>>>>the maximum pool size has been reached ?
>>>>
>>>>>>>"Unspecified" errors generally means you don't have a Try/Catch
>>>>>>>block to trap the specific exception. In Access/JET, yes it
>>>>>>>might mean the pool is full or the database is corrupt, or
>>>>>>>almost anything else.
>>>>
>>>>
>>>>>
>>>> Dim swError As StreamWriter
>>>> Dim sSub As String
>>>> Try
>>>> sSub = "1"
>>>> ConnectionOLE = New OleDb.OleDbConnection
>>>> OpenDBOLE = True
>>>> With ConnectionOLE
>>>> .ConnectionString = 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(Application.StartupPath
>>>>& "\AQErrorLog" & Date.Now.ToString("MMddyy") & ".txt", True)
>>>> swError.Write(Now & " OpenDBOLE - error = " &
>>>>ex.Message & " sub = " & sSub & " g_dbPath = " & g_dbPath &
>>>>vbCrLf)
>>>> swError.Close()
>>>> swError = Nothing
>>>> End Try
>>>>>
>>>>Thank you.
>>>>>
>>>>>
>>>>>
>>>>"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comwrote in
>>>>message news:u2****************@TK2MSFTNGP02.phx.gbl...
>>>>>>I don't think there are any system counters exposed by the JET
>>>>>>provider 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
>>>>>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
>>>>>>
>>>>>--
>>>>>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" <fn****@pfmail.comwrote in message
>>>>>news:ej**************@TK2MSFTNGP03.phx.gb l...
>>>>>>>I am using VS2003 and connecting to MS Access database.
>>>>>>When using a connection pooling (every time I open the
>>>>>>OLEDBCONNECTION 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 ?
>>>>>>>
>>>>>>ConnectionDemoOLE = New OleDb.OleDbConnection
>>>>>>sPath = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
>>>>>>sDBPath & ";OLE DB
>>>>>>Services=-1"
>>>>>>With ConnectionDemoOLE
>>>>>> .ConnectionString = sPath
>>>>>> .Open() --what happens here when the maximum pool size has
>>>>>>been reached ?
>>>>>>>
>>>>>>Thanks
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>




Apr 18 '07 #19
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.OleDbCommand
Dim da As OleDb.OleDbDataAdapter
Dim ds As DataSet
Dim ConnectionDemoOLE As OleDb.OleDbConnection
With cmd
bDBSuccess = OpenDBDemoOLE(ConnectionDemoOLE)
If bDBSuccess Then
.Connection = ConnectionDemoOLE
.CommandText = sql
da = New OleDb.OleDbDataAdapter
ds = New DataSet
da.SelectCommand = cmd
da.Fill(ds)
:
"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comwrote in message
news:uH**************@TK2MSFTNGP04.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
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" <fn****@pfmail.comwrote in message
news:OD**************@TK2MSFTNGP02.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
ConnectionString 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@NoSpamAtAll_betav.comwrote in message
news:%2****************@TK2MSFTNGP03.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
ConnectionString 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" <fn****@pfmail.comwrote in message
news:%2****************@TK2MSFTNGP04.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.OleDbCommand
Dim da As OleDb.OleDbDataAdapter
Dim ds As DataSet
Dim ConnectionDemoOLE As OleDb.OleDbConnection
With cmd
'----DO NOT NEED THIS CODE ----- bDBSuccess =
OpenDBDemoOLE(ConnectionDemoOLE) ------'
'----If bDBSuccess Then
.Connection = ConnectionDemoOLE '????
.CommandText = sql
Try
da = New OleDb.OleDbDataAdapter
ds = New DataSet
da.SelectCommand = cmd
da.Fill(ds)
CloseConDemoOLE(ConnectionDemoOLE)
Catch ex As Exception
end try

Thank you.

"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comwrote in message
news:ul**************@TK2MSFTNGP05.phx.gbl...
CP::Connection 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" <fn****@pfmail.comwrote in message
news:eg**************@TK2MSFTNGP02.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.OleDbCommand
>Dim da As OleDb.OleDbDataAdapter
>Dim ds As DataSet
>Dim ConnectionDemoOLE As OleDb.OleDbConnection
>With cmd
> bDBSuccess = OpenDBDemoOLE(ConnectionDemoOLE)
> If bDBSuccess Then
> .Connection = ConnectionDemoOLE
> .CommandText = sql
> Try
> da = New OleDb.OleDbDataAdapter
> ds = New DataSet
> da.SelectCommand = cmd
> da.Fill(ds)
> CloseConDemoOLE(ConnectionDemoOLE)
> Catch ex As Exception
> end try
> Sub CloseConDemoOLE(ByRef ConnectionDemoOLE As
>OleDb.OleDbConnection)
> If Not ConnectionDemoOLE Is Nothing Then
> ConnectionDemoOLE.Close()
> ConnectionDemoOLE = Nothing
> End If
> End Sub
>>
> Function OpenDBDemoOLE(ByRef ConnectionDemoOLE As
>OleDb.OleDbConnection) As Boolean
> Try
> ConnectionDemoOLE = New OleDb.OleDbConnection
> OpenDBDemoOLE = True
> With ConnectionDemoOLE
> .ConnectionString = g_dbPathDemo
> .Open()
> If .State = ConnectionState.Closed Then
> CloseConDemoOLE(ConnectionDemoOLE)
> OpenDBDemoOLE = False
> End If
> End With
> Catch ex As Exception
>end try
>>
>"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comwrote in
>message news:Or**************@TK2MSFTNGP04.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 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
>>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" <fn****@pfmail.comwrote in message
>>news:OU**************@TK2MSFTNGP06.phx.gbl.. .
>>>Thank you.
>>>I do use try/catch, but I get the "Unspecified 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.OleDbConnection
>>> OpenDBOLE = True
>>> With ConnectionOLE
>>> .ConnectionString = 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.
>>>>
>>>"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comwrote in
>>>message news:Ol****************@TK2MSFTNGP02.phx.gbl...
>>>>See >>>>>
>>>>>
>>>>--
>>>>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" <fn****@pfmail.comwrote in message
>>>>news:%2****************@TK2MSFTNGP03.phx.g bl...
>>>>>>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
>>>>>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 "Unspecified
>>>>>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 "Unspecified error" on the Open method caused
>>>>>by the maximum pool size has been reached ?
>>>>>
>>>>>>>>"Unspecified" errors generally means you don't have a
>>>>>>>>Try/Catch block to trap the specific exception. In Access/JET,
>>>>>>>>yes it might mean the pool is full or the database is corrupt,
>>>>>>>>or almost anything else.
>>>>>
>>>>>
>>>>>>
>>>>> Dim swError As StreamWriter
>>>>> Dim sSub As String
>>>>> Try
>>>>> sSub = "1"
>>>>> ConnectionOLE = New OleDb.OleDbConnection
>>>>> OpenDBOLE = True
>>>>> With ConnectionOLE
>>>>> .ConnectionString = 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(Application.StartupPath
>>>>>& "\AQErrorLog" & Date.Now.ToString("MMddyy") & ".txt", True)
>>>>> swError.Write(Now & " OpenDBOLE - error = " &
>>>>>ex.Message & " sub = " & sSub & " g_dbPath = " & g_dbPath &
>>>>>vbCrLf)
>>>>> swError.Close()
>>>>> swError = Nothing
>>>>> End Try
>>>>>>
>>>>>Thank you.
>>>>>>
>>>>>>
>>>>>>
>>>>>"William (Bill) Vaughn" <billva@NoSpamAtAll_betav.comwrote in
>>>>>message news:u2****************@TK2MSFTNGP02.phx.gbl...
>>>>>>>I don't think there are any system counters exposed by the JET
>>>>>>>provider 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 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
>>>>>>>
>>>>>>--
>>>>>>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" <fn****@pfmail.comwrote in message
>>>>>>news:ej**************@TK2MSFTNGP03.phx.g bl...
>>>>>>>>I am using VS2003 and connecting to MS Access database.
>>>>>>>When using a connection pooling (every time I open the
>>>>>>>OLEDBCONNECTION 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 ?
>>>>>>>>
>>>>>>>ConnectionDemoOLE = New OleDb.OleDbConnection
>>>>>>>sPath = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
>>>>>>>sDBPath & ";OLE DB
>>>>>>>Services=-1"
>>>>>>>With ConnectionDemoOLE
>>>>>>> .ConnectionString = sPath
>>>>>>> .Open() --what happens here when the maximum pool size
>>>>>>>has been reached ?
>>>>>>>>
>>>>>>>Thanks
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>




Apr 18 '07 #20
On Wed, 18 Apr 2007 09:21:38 -0500, "fniles" <fn****@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)
Apr 19 '07 #21

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

Similar topics

18
by: Rob Nicholson | last post by:
We're getting an occasional occurrence of the following error when two users try and open the same record in our ASP.NET app: "There is already an open DataReader associated with this Connection...
1
by: Lenny Shprekher | last post by:
Hi, I am getting issues that Oracle collecting opened sessions (connections) from my webservice using regular System.Data.OleDb.OleDbConnection object. I am guessing that this is connection...
5
by: Zlatko Matić | last post by:
Hello. In ODBC Data Source Administrator, there is a tab "Connection Pooling" and option "PerfMon" Enable/Disable. Could someone explain the meaning of the option and how it reflects to Access...
7
by: Mrinal Kamboj | last post by:
Hi , I am using OracleConnection object from Oracle ODP.net provider and following is the behaviour which i am finding bit strange : To start with my argument is based on followings facts : ...
16
by: crbd98 | last post by:
Hello All, Some time ago, I implemented a data access layer that included a simple connectin pool. At the time, I did it all by myself: I created N connections, each connection associated with...
3
by: fniles | last post by:
In the Windows application (using VB.NET 2005) I use connection pooling like the following: In the main form load I open a connection using a connection string that I stored in a global variable...
0
viswarajan
by: viswarajan | last post by:
Introduction This article is to go in deep in dome key features in the ADO.NET 2 which was shipped with VS 2005. In this article I will go trough one of the key features which is the Connection...
15
by: Sylvie | last post by:
I have a static function in a class, everytime I call this function, I am creating a SQLconnection, open it, use it, and null it, All my functions and application logic is like this, Every...
6
by: TheSteph | last post by:
Hi, (using C#, VS2005, .NET 2.0.) I sometimes need to access my database (SQL Server) in SINGLE_USER mode.
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.