Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: .NET1.1 .NET2.0 C#2.0 .NET3.0 , +
How can i sove th error :Cannot find table 0.? what could be the reason?
getting error in this code,
 
DataSet xxx= new DataSet();
dt = xx.Tables[0].DefaultView.ToTable(true, "Fieldname");
 
Please help me.
 
A big thanks in advance
Posted 5-Mar-13 4:57am
Kavitha_b1.4K
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

try this:
 DataSet dataSetObject = new DataSet();
 sqlDataAdapterObject.Fill(dataSetObject);
 DataTable dataTableObject = dataSetObject.Tables[0].DefaultView.ToTable(true, "Fieldname");
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

The place where you are binding your dataset, put a break point and see. Your dataset is empty, that's why it cannot find table 0.
For example if you are using a procedure to get the data and that you are binding to the dataset, then your procedure is not returning any row.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

The reason could be that you wrote
 
xx.Tables["0"]
 
instead of
 
xx.Tables[0]
 
Difficult to say more, as the code you provided would not even compile.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Your DataSet is "xxx" and you are using "xx" in the second line of code.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 400
1 Sergey Alexandrovich Kryukov 329
2 Afzaal Ahmad Zeeshan 264
3 BillWoodruff 245
4 CPallini 195
0 OriginalGriff 5,560
1 DamithSL 4,476
2 Maciej Los 3,942
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,175


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 5 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100