Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Your code seems to be missing the defintion of tbl. I assume it is something like</p> <pre><code>DataTable tbl = MyConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null); </code></pre> <p>If so, you will probably get the sheetnames but in the wrong order.</p> <p>I could not find a proper solution for this issue, so I approached it from another point of view. I decided to look for sheets that actual had information on it. You can probably do this by looking at the rows, but the method I used was to look at the columns from the schema information. (This obviously will fail in your used sheet only has one column as unused sheets also have one column), but it worked in my case, and I also used it to check I had the expected number of columns (in my case nine)</p> <p>This uses the GetOleDbSchemaTable(OleDbSchemaGuid.Columns, null) method to return the column information.</p> <p>The code is probably irrelevant/trival, and as I happened to be learning LINQ when I came across this issue, so I wrote it in LINQ style </p> <p>It does require a small class called LinqList which you can get <a href="https://blog.rthand.com/post/2006/01/15/284.aspx" rel="nofollow noreferrer">here</a></p> <pre><code>DataTable columnDetails = objConn.GetOleDbSchemaTable( System.Data.OleDb.OleDbSchemaGuid.Columns, null); LinqList&lt;DataRow&gt; rows = new LinqList&lt;DataRow&gt;(columnDetails.Rows); var query= (from r in rows group r by r["Table_Name"] into results select new { results.Key , count=results.Count() } ); var activeSheets = (from sheet in query where sheet.count == 9 select sheet.Key ).ToList(); if (activeSheets.Count != 1) ... display error </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload