PDA

Click to See Complete Forum and Search --> : MS Access and asp.net Problem...UGHH!!


bebandit
Apr 4th, 2005, 02:03 PM
I have a asp.net that uses an access 2003 database. I get this strange event where the page will work for 10 or so times and then I get this:

Line 144:
Line 145:
Line 146: myConnection.Open()
Line 147:
Line 148: 'Create an OleDbCommand object.


Source File: C:\Components\ProductsDB.vb Line: 146

Stack Trace:


[OleDbException (0x80004005): Unspecified error]
System.Data.OleDb.OleDbConnection.ProcessResults(Int32 hr)
System.Data.OleDb.OleDbConnection.InitializeProvider()
System.Data.OleDb.OleDbConnection.Open()
IBuySpy.IBuySpy.ProductsDB.GetMainCategories() in C:\Documents and Settings\Administrator\Desktop\Components\ProductsDB.vb:146
IBuySpy.C_Menu2.Page_Load(Object sender, EventArgs e) in C:\Documents and Settings\Administrator\Desktop\_Menu2.ascx.vb:57
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()



What is so strange is that it works for a while and then just cuts out.
The error message (what line the error is on) changes but it always happens
when it is going to open a connection to the database. I've checked to make
sure that all connections were closed before I opened another. Any Ideas?

bebandit
Apr 5th, 2005, 11:52 AM
I found out what it was - with no help from Microsoft!!

If you are using an Access database with ASP.net, it would be a good prcatice not to open two connections to a database at the same time.

For instance, I have a datalist that is databound in the Page_Load event.
In that datagrid is a function that gets the category name for the database.
This function opens up another connection to the database.

This is a No-No as I receive an unhadled exception error after refreshing the page 10 or 12 times. To get around this, I declared a public variable as a string in the Codebehind and ran the function once in the Page_Load event. I then put that global variable in the datagrid instead of calling the function over and over again. This also make the page load quicker and decreases the number of times the Database gets hit with requests.

So if you get the Error Message: Error '80004005' Unexpected Error after refreshing several times, try making sure that all your connection strings are properly closed and that you don't have more than one connection open at a time. this can happen in datalists,repeaters,datagrids and when using for and while loops.

Hope this helps someone! :duck: :duck: :duck: