Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Cannot find table 0

Author  Topic 

adya
Starting Member

31 Posts

Posted - 2009-01-26 : 20:19:00
Hi

I am getting this sporadic error: System.IndexOutOfRangeException: Cannot find table 0.

It occurs every now and then and I have tried debugging the application, but it never seems to happen when i want to recreate it.

The code is as follows:
public DataTable Jobs
{
get
{
SqlCommand command = new SqlCommand("SchShowAllSchedule", ConnectionUtil.OpenConnection);
command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@ResId", ResId); command.Parameters.AddWithValue("@DateStart", startDate);
command.Parameters.AddWithValue("@DateEnd", endDate);
SqlDataAdapter adapter = new SqlDataAdapter(command);
DataSet ds = new DataSet();
adapter.Fill(ds);
if (ds.Tables.Count != 0 && ds.Tables[0] != null)
{
DataTable table = ds.Tables[0];
return table;
}
else
return null;
}
}

The stack trace is:
Error: System.IndexOutOfRangeException: Cannot find table 0.
at System.Data.DataTableCollection.get_Item(Int32 index)
at ScheduleCom.Resource.get_Jobs()
at ScheduleCom.Resource.get_Indices()
at ScheduleCom.GraphCreator.CreateUserRow(DataRow row, String Name, String checkBoxId, String hiddenId, String rowId, Int32 TotalCols, Int32 ResId, DateTime DateStart, DateTime DateEnd)
at ScheduleCom.GraphCreator.CreateGrid(DateTime startingDate, String branchId)
at ScheduleCom.GraphCreator.GenerateGraph(DateTime startingDate, String branchId)
at WorkFlow.Scheduler._default.Page_Load(Object sender, EventArgs e)
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Adya

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-01-26 : 20:25:43
table 0 isn't referring to a SQL Server table. I believe it's referring to a .NET data table. You might have better luck if you asked your question on a .NET forum, such as over at www.asp.net

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -