Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am running my .net application localhost and it is running fine fetching data from database while i am running my application on live server it is giving me the error of table 0 not found and ArrayIndexoutofboundexception

Server Error in '/' Application.

Cannot find table 0.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IndexOutOfRangeException: Cannot find table 0.

Source Error:


Line 41: else { OID = Request.QueryString["u"].ToString(); }
Line 42: DataSet ds = myAdmin.getPassCodeAMIN(OID);
Line 43: if (ds.Tables[0].Rows.Count > 0)
Line 44: {
Line 45:

Source File: c:\inetpub\vhosts\ip-pabx.com\httpdocs\LoginAction.aspx.cs Line: 43

Stack Trace:


[IndexOutOfRangeException: Cannot find table 0.]
System.Data.DataTableCollection.get_Item(Int32 index) +92
LoginAction.Page_Load(Object sender, EventArgs e) in c:\inetpub\vhosts\ip-pabx.com\httpdocs\LoginAction.aspx.cs:43
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

Version Information: Microsoft .NET Framework Version:2.0.50727.3662; ASP.NET Version:2.0.50727.3668
Posted
Updated 4-Jul-15 0:41am
v2
Comments
harpreet.singh6771 4-Jul-15 7:14am    
myAdmin.getPassCodeAMIN(OID)


please ellaborate the class file so i can help u

1 solution

C#
DataSet ds = myAdmin.getPassCodeAMIN(OID);

in above line if getPassCodeAMIN not returning any DataTable, when you call ds.Tables[0].Rows it will give you exception, you better check table count before checking row count
C#
if (ds.Tables.Count>0 && ds.Tables[0].Rows.Count > 0)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900