473,721 Members | 2,217 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 2345

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

Similar topics

2
2128
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
2435
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
1322
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
2654
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
5131
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
2519
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
1952
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
2174
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
8738
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
9376
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
9086
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8028
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6678
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5994
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
4762
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3207
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2146
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.