Click here to Skip to main content
15,891,513 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Cannot find table 0.
Posted on: 23 Jul 2013
this is my display function it shows error Cannot find table 0.

C#
public void display()
   {

           DataSet ds = new DataSet();
           ds = DB.ExecuteQuery_SP("displayDetails");
           GridView1.DataSource = ds.Tables[0];
           GridView1.DataBind();

protected void btnSave_Click(object sender, EventArgs e)
   {
       ThreadStart DisplayThread = new ThreadStart(display);
       Thread t2 = new Thread(DisplayThread);
       t2.Start();
       display();


       ThreadStart InsertionThread = new ThreadStart(insertion);
       Thread t1 = new Thread(InsertionThread);
       t1.Priority = ThreadPriority.Highest;
       t1.Start();
       //insertion();

       ThreadStart MailThread = new ThreadStart(Mail);
       Thread t3 = new Thread(MailThread);
       t3.Start();
       //Mail();
       display();
       DataSet ds = new DataSet();
       ds = DB.ExecuteQuery_SP("displayDetails");
       GridView1.DataSource = ds.Tables[0];
       GridView1.DataBind();
Posted
Updated 23-Jul-13 1:54am
v2
Comments
Jameel VM 23-Jul-13 7:53am    
Please check the query that you try to execute.
ZurdoDev 23-Jul-13 7:58am    
That's because the query is returning no results.
Mohammed Shamsheer 24-Jul-13 0:34am    
query is returning
ZurdoDev 24-Jul-13 7:45am    
Actually, I really doubt it. The error is saying it is not. If so, point out the line of code that is causing the error and what the exact error is.
Joezer BH 23-Jul-13 8:11am    
maybe it's because there is no table 0 ...
did you check the SP for the return dataset (that it has the tables you want)?

1 solution

Hi Shamsheer,

I hope, the store procedure that you are calling does'nt hold the results that you are intended to display.
I suggest you to add this condition before reading data from table[0].Like this

C#
public void display()
        {
           DataSet ds = new DataSet();
           ds = DB.ExecuteQuery_SP("displayDetails");
           if (ds.Tables.Count > 0 )
           {
               GridView1.DataSource = ds.Tables[0];
               GridView1.DataBind();
           }
        }

else you can refer this link[^]
I hope this could help you a bit.

Thanks,
RK
 
Share this answer
 

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



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