473,659 Members | 3,395 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GetOleDbSchemaT able bug (!) not all columns

Hi. I'm trying to read the structure of some Excel 2000 file that the
user is expected to upload. The file must be an excel file (solved)
and it must contain a column named "PIN". That's all. Now about the
column name.

I have the code:

cnExcel.Connect ionString = "Provider=Micro soft.Jet.OLEDB. 4.0;Data
Source=" & strTableName & ";Extended Properties=""Ex cel
8.0;HDR=Yes;IME X=1"";"
cnExcel.Open()

'Retrieve schema information about the excel file (i.e the name of the
first sheet in the worksheet).
schemaTable = cnExcel.GetOleD bSchemaTable(Ol eDbSchemaGuid.T ables, New
Object() {Nothing, Nothing, Nothing, "TABLE"})
strSheetName = schemaTable.Row s(0).Item("Tabl e_Name").ToStri ng

'Retrieve the collection of columns in this excel file...
schemaTable = cnExcel.GetOleD bSchemaTable(Ol eDbSchemaGuid.C olumns, New
Object() {Nothing, Nothing, strSheetName, Nothing})

'Check if we have at least the "PIN" column:
If schemaTable.Sel ect("COLUMN_NAM E='PIN'").GetUp perBound(0) < 0 Then
.....

I have tried with multiple files. Sometimes it
- returns schemaTable.Row s.Count=0 (no columns !!!)
- returns all columns, and I can see them nicely in the immediate
window
- returns only some columns - say the file has 5 columns, but I can
only see 4 - schemaTable.Row s.Count = 4 and ?schemaTable.Ro ws(4)!
COLUMN_NAME.ToS tring tells me that this index does not exist

I have tried moving the PIN column back and forth in the excel file,
and to my astonishment... . sometimes it works.

Example:

Col1 PIN Col2 Status
1 1 63 AAA
2 1 27 AAA
3 1 82 AAA
3 1 40 AAA
4 1 52 AAA
1 1 5 AAA
2 1 11 AAA
3 1 11 AAA
3 1 17 AAA

gives
?schemaTable.Ro ws(0)!COLUMN_NA ME.ToString
"Col1"
?schemaTable.Ro ws(1)!COLUMN_NA ME.ToString
"Col2"
?schemaTable.Ro ws(2)!COLUMN_NA ME.ToString
"PIN"
?schemaTable.Ro ws(3)!COLUMN_NA ME.ToString
Run-time exception thrown : System.IndexOut OfRangeExceptio n - There is
no row at position 3.
(No Status ???)

Col1 Col2 Status PIN
1 653 AAA 1
2 27 AAA 1
3 892 AAA 1
3 40 AAA 1
4 52 AAA 1
1 5 AAA 1
2 151 AAA 1
3 11 AAA 1
3 1472 AAA 1


?schemaTable.Ro ws(0)!COLUMN_NA ME.ToString
"Col1"
?schemaTable.Ro ws(1)!COLUMN_NA ME.ToString
"Col2"
?schemaTable.Ro ws(2)!COLUMN_NA ME.ToString
Run-time exception thrown : System.IndexOut OfRangeExceptio n - There is
no row at position 2.
(No PIN ??? No Status ??? Now two columns dropped ???)

This one
Col1 SS_Col2 Col3 PIN SS_Col4
1 5 AAA 1 2
2 6 AAA 1 3
3 7 AAA 1 4
3 8 AAA 1 5
4 9 AAA 1 6
1 10 AAA 1 7
2 11 AAA 1 8
3 12 AAA 1 9
3 13 AAA 1 10

gives

?schemaTable.Ro ws(0)!COLUMN_NA ME.ToString
"Col1"
?schemaTable.Ro ws(1)!COLUMN_NA ME.ToString
"SS_Col2"
?schemaTable.Ro ws(2)!COLUMN_NA ME.ToString
Run-time exception thrown : System.IndexOut OfRangeExceptio n - There is
no row at position 2.

.... and so on. I have tried many combinations. This situation doesn't
have neither rhyme nor reason. Can somebody hep me, please ?

Thanks a lot.
Alex
Jun 27 '08 #1
0 2327

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2122
by: Kevin | last post by:
Hi Al Can someone tell me how to hide colums in a datagrid. I have a one datagrid that is a master and child and I would like to hide specific columns, how do I do this TI Kevin
1
2432
by: pete | last post by:
Hi All, I am trying to get the field desriptions from SQL Server 2000 using GetOleDbSchemaTable (see code below) Now this returns a description field to the DataTable, but the field is empty. I know my fields have descrptions assigned to them. Has anyone seen this before, is it a bug in ASP.NET. or am I missing something? I am using win2000 server / IIS5 / .NET v1.0.3705 /
0
1317
by: cosmos | last post by:
Hello, I am using Microsoft Indexing Server, and it seems that ADO.NET OLEDB Connection object doesn't support the GetOleDbSchemaTable method with MSIDXS OLE DB provider. I get the following errors: IDBSchemaRowset interface is not supported by the 'MSIDXS' provider. is unavailable with the current provider.
5
2648
by: Gary Blakely | last post by:
I'm giving this post another try - it can't be too difficult for everyone.... In the program below, the web page has dataGrid1. the only thing that has been done to it at design time is to check the "Create columns automatically at runtime" checkbox - nothing else. The code below does indeed create the visual grid as expected. Furthermore the Cell contents and Item count all exist and contain expected values. However there is no...
7
5118
by: Marcus | last post by:
I need to write a VB.Net application that will take an mdb file (Access 2000) and create corresponding copy of it in SQL Express, creating all the tables and relationships, and transferring over the data (using an existing application like DTS in SQL Server or something else is NOT an option - this must be coded from scratch). The Access databases that it must be able to handle will only have tables, relationships, and data (i.e. no...
0
2512
by: bjgroot | last post by:
GetOleDbSchemaTable ________________________________________ With the code down here, I can find all the Table Names of a database in Access, but ........ I like to know also the query-names of that database. Can anybody tell me how to do this ? ? I can't find it. Greetings Bas.
0
1942
by: bappelsin | last post by:
Hello, I have a problem with the datagridview. I have a view with around 25 different columns. To make life easier for the users I have implemented a popup dialog where the user can select which columns that should be displayed and in which order the columns are shown. After user has selected the visible columns and the order he presses ok. The grid is first cleared from rows, then I add all visible columns and then all hidden. Grid is...
5
2162
by: explode | last post by:
I made a procedure Public Sub Novo(ByVal nova1 As String, ByVal nova2 As String) that creates a new oledbDataAdapter with insert update select and delete commads. I also added that commands can change depending how many columns are in a Table. I add a new column with this code: Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click Try...
0
201
by: Radu | last post by:
Hi. I'm trying to read the structure of some Excel 2000 file that the user is expected to upload. The file must be an excel file (solved) and it must contain a column named "PIN". That's all. Now about the column name. I have the code: -------------------------------------------------------------------------------------------------------- cnExcel.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strTableName &...
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8337
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8748
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8531
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1978
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1739
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.