asp.net and Access 2000 - fails to connect after awhile

M

mark

I have a asp.net web application that uses an access 2000
database on the backend. I've been programming asp 3.0
apps with access for a couple of years know and haven't
run into this problem before. I'm using forms
authentication with a login page. After login a .ldb lock
is put on the database and after browsing for a few
minutes the size of the access db grows from about 500k to
2.5 mb. After browsing the site for about 10 minutes the
asp.net script fails to make any further connections to
the access db. This isn't related to a specific spot that
would point to a code problem. I went back and made sure
I close all connections and readers and even
called .dispose on all connections. When this problem
occurs it brings down the entire site for all other users
trying to access over the web. I upload a fresh
web.config file to reset the site and it's good for
another 10 minutes before the same thing happens again.

sample data access code:
Dim myConnection As OleDbConnection = New
OleDbConnection(ConfigurationSettings.AppSettings
("ConnectionString"))
Dim myCommand As OleDbCommand = New
OleDbCommand("qProductInfo", myConnection)
myCommand.CommandType =
CommandType.StoredProcedure

Dim parameterProductID As OleDbParameter = New
OleDbParameter("ProductID", OleDbType.VarChar, 50)
parameterProductID.Value = productID
myCommand.Parameters.Add(parameterProductID)

Dim Item As String
Dim Description As String
Dim ImageH As String
Dim ImageW As String
Dim Min As Integer
Dim CMin_Ok As Boolean
Dim Instock As Boolean

Try
myConnection.Open()
Dim rs As OleDbDataReader =
myCommand.ExecuteReader
Dim myProductDetails As ProductDetails =
New ProductDetails()

While rs.Read
myProductDetails.Item = Replace(rs
("ITEM"), "^", "'")
myProductDetails.Description = Replace
(rs("DESCRIPTION"), "^", "'")
myProductDetails.ImageH = rs("H")
myProductDetails.ImageW = rs("W")
myProductDetails.Instock = rs
("INSTOCK")
myProductDetails.Min = rs("MIN")
myProductDetails.CMin_Ok = rs("CMIN")
End While
Return myProductDetails
rs.Close()
myCommand.Dispose()
myConnection.Close()
myConnection.Dispose()
myConnection = Nothing
Catch
Return Nothing
End Try
GC.Collect()
 
A

Angel Saenz-Badillos[MS]

The code looks good, try moving all of your code cleanup to a Finally clause
and let me know if it still repros.
Could you post the error message/stack?

Thanks.
 
M

mark

Thanks for the reply. Will try that. Basically I have a
menu that shows on all pages, this seems to usually be the
first to be affected by this problem. It fails to open
the connection and thus the menu is not populated. Then
after this occurs, I will get "an object was not based on
an instance of an object" error some where down the road
in another file. This object error isn't always the same
file. It seems like the next page I go to after the menu
stops working is where I get the object error.
Does this seem to be an Access connection problem, since
when it happens it brings down the entire site for all
other users as well? Late yesterday I realized I had
uploaded the site to the web server but had left it in
debug mode when I built it. I read somewhere that this
normally puts a large tax on resorces. I switch to
release mode and rebuilt and ftp'd the site and the same
error popped up again a few moments later.
-----Original Message-----
The code looks good, try moving all of your code cleanup to a Finally clause
and let me know if it still repros.
Could you post the error message/stack?

Thanks.

--
Angel Saenz-Badillos [MS] Managed Providers
This posting is provided "AS IS", with no warranties, and confers no rights.
Please do not send email directly to this alias. This alias is for newsgroup
purposes only.

mark said:
I have a asp.net web application that uses an access 2000
database on the backend. I've been programming asp 3.0
apps with access for a couple of years know and haven't
run into this problem before. I'm using forms
authentication with a login page. After login a .ldb lock
is put on the database and after browsing for a few
minutes the size of the access db grows from about 500k to
2.5 mb. After browsing the site for about 10 minutes the
asp.net script fails to make any further connections to
the access db. This isn't related to a specific spot that
would point to a code problem. I went back and made sure
I close all connections and readers and even
called .dispose on all connections. When this problem
occurs it brings down the entire site for all other users
trying to access over the web. I upload a fresh
web.config file to reset the site and it's good for
another 10 minutes before the same thing happens again.

sample data access code:
Dim myConnection As OleDbConnection = New
OleDbConnection(ConfigurationSettings.AppSettings
("ConnectionString"))
Dim myCommand As OleDbCommand = New
OleDbCommand("qProductInfo", myConnection)
myCommand.CommandType =
CommandType.StoredProcedure

Dim parameterProductID As OleDbParameter = New
OleDbParameter("ProductID", OleDbType.VarChar, 50)
parameterProductID.Value = productID
myCommand.Parameters.Add(parameterProductID)

Dim Item As String
Dim Description As String
Dim ImageH As String
Dim ImageW As String
Dim Min As Integer
Dim CMin_Ok As Boolean
Dim Instock As Boolean

Try
myConnection.Open()
Dim rs As OleDbDataReader =
myCommand.ExecuteReader
Dim myProductDetails As ProductDetails =
New ProductDetails()

While rs.Read
myProductDetails.Item = Replace(rs
("ITEM"), "^", "'")
myProductDetails.Description = Replace
(rs("DESCRIPTION"), "^", "'")
myProductDetails.ImageH = rs("H")
myProductDetails.ImageW = rs("W")
myProductDetails.Instock = rs
("INSTOCK")
myProductDetails.Min = rs("MIN")
myProductDetails.CMin_Ok = rs ("CMIN")
End While
Return myProductDetails
rs.Close()
myCommand.Dispose()
myConnection.Close()
myConnection.Dispose()
myConnection = Nothing
Catch
Return Nothing
End Try
GC.Collect()


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top