|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Sporadic Error: Cannot find table 0Essentially, the application uses a single shared Connection object for all users logged into the system. The connection object is opened/closed for each transaction. The error - System.IndexOutOfRangeException: Cannot find table 0 - occurs on one page that accepts a single piece of data from a textbox. This data is then passed to the business logic classes (in VB.Net) and is queried against the database. According to the stack trace, the error occurs at: System.Data.DataTableCollection.get_Item(Int32 index) +79 Out of 100 data entries, this error will appear once or twice. Note also that when the user enters the same piece of data that caused the initial run-time error, the second entry executes OK! Any suggestions? Thanks: Pat Pat,
The problem is in your logic. When that error occurs, you are getting a dataset with no tables back. At the very line the error happens, you can put checking code like this if (Dataset.Tables.Count == 0) // show the user that no data was fetched else // your current logic - Sahil Malik http://codebetter.com/blogs/sahil.malik/ Show quoteHide quote "POL8985" <pol8***@njit.edu> wrote in message news:1107016795.289246.6550@c13g2000cwb.googlegroups.com... > The application is developed in ASP.Net with a SQL Server database. > > Essentially, the application uses a single shared Connection object for > all users logged into the system. The connection object is > opened/closed for each transaction. > > The error - System.IndexOutOfRangeException: Cannot find table 0 - > occurs on one page that accepts a single piece of data from a textbox. > This data is then passed to the business logic classes (in VB.Net) and > is queried against the database. > > According to the stack trace, the error occurs at: > System.Data.DataTableCollection.get_Item(Int32 index) +79 > > Out of 100 data entries, this error will appear once or twice. Note > also that when the user enters the same piece of data that caused the > initial run-time error, the second entry executes OK! > Any suggestions? > > Thanks: > > Pat > Like Sahil mentions- you should check the DataSet.Tables.Count property
before trying to access it - but why this is happening is also of concern. As a general point - what benefit do you get from only having one connection object shared throughout everything? -- Show quoteHide quoteW.G. Ryan MVP (Windows Embedded) TiBA Solutions www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com "POL8985" <pol8***@njit.edu> wrote in message news:1107016795.289246.6550@c13g2000cwb.googlegroups.com... > The application is developed in ASP.Net with a SQL Server database. > > Essentially, the application uses a single shared Connection object for > all users logged into the system. The connection object is > opened/closed for each transaction. > > The error - System.IndexOutOfRangeException: Cannot find table 0 - > occurs on one page that accepts a single piece of data from a textbox. > This data is then passed to the business logic classes (in VB.Net) and > is queried against the database. > > According to the stack trace, the error occurs at: > System.Data.DataTableCollection.get_Item(Int32 index) +79 > > Out of 100 data entries, this error will appear once or twice. Note > also that when the user enters the same piece of data that caused the > initial run-time error, the second entry executes OK! > Any suggestions? > > Thanks: > > Pat > In my opinion, there is no benefit of having a single connection object if
your underlying data provider supports connection pooling, and I am willing to argue that point till the cows come home. - Sahil Malik http://codebetter.com/blogs/sahil.malik/ Show quoteHide quote "W.G. Ryan eMVP" <WilliamRyan@NoSpam.gmail.com> wrote in message news:OonAQ4iBFHA.1396@tk2msftngp13.phx.gbl... > Like Sahil mentions- you should check the DataSet.Tables.Count property > before trying to access it - but why this is happening is also of concern. > As a general point - what benefit do you get from only having one > connection > object shared throughout everything? > > -- > W.G. Ryan MVP (Windows Embedded) > > TiBA Solutions > www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com > "POL8985" <pol8***@njit.edu> wrote in message > news:1107016795.289246.6550@c13g2000cwb.googlegroups.com... >> The application is developed in ASP.Net with a SQL Server database. >> >> Essentially, the application uses a single shared Connection object for >> all users logged into the system. The connection object is >> opened/closed for each transaction. >> >> The error - System.IndexOutOfRangeException: Cannot find table 0 - >> occurs on one page that accepts a single piece of data from a textbox. >> This data is then passed to the business logic classes (in VB.Net) and >> is queried against the database. >> >> According to the stack trace, the error occurs at: >> System.Data.DataTableCollection.get_Item(Int32 index) +79 >> >> Out of 100 data entries, this error will appear once or twice. Note >> also that when the user enters the same piece of data that caused the >> initial run-time error, the second entry executes OK! >> Any suggestions? >> >> Thanks: >> >> Pat >> > > Thank you Sahil, WG for your suggestions.
Technically, the IndexOutOfRangeException should never occur because the data being entered in the ASPX page is actually in the database (and should return the corresponding set of records in my DataSet.Table(0))! We've actually never paid explicit attention to connection pooling and hope this would be key to solving our problem. Allow me to give you a bit more background into the application. The ASP.Net application references two DLLs that provide 100% of the business logic. Each of these DLLs performs all SQL Server transactions via a data access class we wrote. Each DLL has one global instance of this data access class (with the same connection string). The data access class uses a single connection object that is open/closed with each transaction. I know that connection pooling is automatically handled by ADO.Net, but how would I explicitly use it to solve this problem? Thanks again: Pat I doubt connection pooling will help solve the problem of not having a table
appear, where you expect it to. Your best bet will still be to try and look at the tables collection just before you get the error. Regards ... > The ASP.Net application references two DLLs that provide 100% of the Again, close your connections as soon as possible, and open as late as > business logic. Each of these DLLs performs all SQL Server > transactions via a data access class we wrote. Each DLL has one global > instance of this data access class (with the same connection string). > The data access class uses a single connection object that is > open/closed with each transaction. ..... possible. I don't think you are doing that above. - Sahil Malik http://codebetter.com/blogs/sahil.malik/ Show quoteHide quote "POL8985" <pol8***@njit.edu> wrote in message news:1107040695.387848.273990@z14g2000cwz.googlegroups.com... > Thank you Sahil, WG for your suggestions. > > Technically, the IndexOutOfRangeException should never occur because > the data being entered in the ASPX page is actually in the database > (and should return the corresponding set of records in my > DataSet.Table(0))! We've actually never paid explicit attention to > connection pooling and hope this would be key to solving our problem. > > Allow me to give you a bit more background into the application. > > The ASP.Net application references two DLLs that provide 100% of the > business logic. Each of these DLLs performs all SQL Server > transactions via a data access class we wrote. Each DLL has one global > instance of this data access class (with the same connection string). > The data access class uses a single connection object that is > open/closed with each transaction. > > I know that connection pooling is automatically handled by ADO.Net, but > how would I explicitly use it to solve this problem? > Thanks again: > > Pat >
Other interesting topics
Problem with ExecuteNonQuery() Result, Access, ASP.NET, C#, ADO, OleDB
Data reader already open? date format in parameter SqlDataReader.GetChar(n) failed because of Specified method unsupp How to simple storage data about colors in database ? What is the Best way to fetch the most recent updated row in a database Question on how I can use ForeignKeyConstraint Cant get Stored Procedure connection string right?? Confused about MissingSchemaAction.AddWithKey protect overflow of sql data type decimal(9,3) |
|||||||||||||||||||||||