D
DraguVaso
Hi,
When I was looking for the reason my application was runnong so slow I
suddenly noticed that it was the opening and closing of the connection that
took almost all the time. Like in most of the samples I found I opened the
connection everytime I needed it, and closed it after my action.
But closing and opening everytime seemed to take very much time, so I opened
my connection at the start of the application, and closed it at the end: it
runned up to 20 times faster (before 1 action took 3-4 seconds, now I have 5
actions per second).
So now my question: what's wrong with opening it one time and closing it at
the end? Looking at the smaples I found this seems 'not done'? Does it
really take so much resources to leave the connection the whole time open?
Isn't the use of a property like this a nicer way to handle the
database-connection?
Property MyConn() As OleDbConnection
Get
If Not MyConn2.State = ConnectionState.Open Then
MyConn2.Open()
End If
MyConn = MyConn2
End Get
Set(ByVal Value As OleDbConnection)
'nothing?
End Set
End Property
or maybe just before every use a:
If Not MyConn.State = ConnectionState.Open Then
MyConn.Open()
End If
Any help, any idea's, any remarks or reflections would be nice. I just
thinks the much better performance justifies to leave the connection open.
Is there any offical documentation about this?
Thanks in advance!
Pieter
When I was looking for the reason my application was runnong so slow I
suddenly noticed that it was the opening and closing of the connection that
took almost all the time. Like in most of the samples I found I opened the
connection everytime I needed it, and closed it after my action.
But closing and opening everytime seemed to take very much time, so I opened
my connection at the start of the application, and closed it at the end: it
runned up to 20 times faster (before 1 action took 3-4 seconds, now I have 5
actions per second).
So now my question: what's wrong with opening it one time and closing it at
the end? Looking at the smaples I found this seems 'not done'? Does it
really take so much resources to leave the connection the whole time open?
Isn't the use of a property like this a nicer way to handle the
database-connection?
Property MyConn() As OleDbConnection
Get
If Not MyConn2.State = ConnectionState.Open Then
MyConn2.Open()
End If
MyConn = MyConn2
End Get
Set(ByVal Value As OleDbConnection)
'nothing?
End Set
End Property
or maybe just before every use a:
If Not MyConn.State = ConnectionState.Open Then
MyConn.Open()
End If
Any help, any idea's, any remarks or reflections would be nice. I just
thinks the much better performance justifies to leave the connection open.
Is there any offical documentation about this?
Thanks in advance!
Pieter