Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Excel ODBC Driver with ADO

Hi,

I'm using ADO with the Excel ODBC driver to query Excel €˜tables, identified
in the FROM clause by the worksheet name, i.e. SELECT * FROM [MySheet$].

My €˜table (i.e. worksheet) contains 160 rows of data. My problem is that
when querying, the driver believes that 11 empty rows below the data are also
part of the €˜table.

According to Microsoft, the €˜table, when querying Excel in this way, is
defined as the €˜UsedRange of the worksheet specified - see
http://support.microsoft.com/kb/278973/EN-US/. However, when I check the
number of rows in ActiveWorksheet.UsedRange it correctly consists of the
first 160 rows only.

Although I *could* workaround by building a string referring to the range of
the UsedRange object, and including that in the FROM clause rather than just
the worksheet name, I'd like to work out what's going on!

I'm wondering if it's a bug in the Excel ODBC Driver...
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Excel ODBC Driver with ADO

I don't know what is going on either (and hard to test unless I could
duplicate the exact conditions of your code and sheet, including all the
steps used in building the sheet since that often affects the UsedRange).

But one easier and more general workaround would be to add a "WHERE" clause
to your SQL that would reject any blank columns; for example if you have a
column called "NAME" you could specify SELECT * FROM [MySheet$] WHERE NAME
<''
--
- K Dales


"TimG" wrote:

Hi,

I'm using ADO with the Excel ODBC driver to query Excel €˜tables, identified
in the FROM clause by the worksheet name, i.e. SELECT * FROM [MySheet$].

My €˜table (i.e. worksheet) contains 160 rows of data. My problem is that
when querying, the driver believes that 11 empty rows below the data are also
part of the €˜table.

According to Microsoft, the €˜table, when querying Excel in this way, is
defined as the €˜UsedRange of the worksheet specified - see
http://support.microsoft.com/kb/278973/EN-US/. However, when I check the
number of rows in ActiveWorksheet.UsedRange it correctly consists of the
first 160 rows only.

Although I *could* workaround by building a string referring to the range of
the UsedRange object, and including that in the FROM clause rather than just
the worksheet name, I'd like to work out what's going on!

I'm wondering if it's a bug in the Excel ODBC Driver...

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Excel ODBC Driver with ADO

The problem could be in the UsedRange, as it might include blank rows but
with formats. You are better off testing for a strong WHERE clause such as

SELECT * FROM [MySheet$] WHERE COL1 < '' OR COL2 < ''
OR COL3 < '' etc


"TimG" wrote:

Hi,

I'm using ADO with the Excel ODBC driver to query Excel €˜tables, identified
in the FROM clause by the worksheet name, i.e. SELECT * FROM [MySheet$].

My €˜table (i.e. worksheet) contains 160 rows of data. My problem is that
when querying, the driver believes that 11 empty rows below the data are also
part of the €˜table.

According to Microsoft, the €˜table, when querying Excel in this way, is
defined as the €˜UsedRange of the worksheet specified - see
http://support.microsoft.com/kb/278973/EN-US/. However, when I check the
number of rows in ActiveWorksheet.UsedRange it correctly consists of the
first 160 rows only.

Although I *could* workaround by building a string referring to the range of
the UsedRange object, and including that in the FROM clause rather than just
the worksheet name, I'd like to work out what's going on!

I'm wondering if it's a bug in the Excel ODBC Driver...

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Excel ODBC Driver with ADO

The strange thing is that UsedRange returns the correct row count (160 rows)
so the ODBC driver is, apparently, not using UsedRange as documented.

Thank you for your input - using a WHERE clause sounds like a more elegant
workaround than what I proposed!

Tim
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Free XML ODBC driver for EXCEL Pete Jones Excel Discussion (Misc queries) 0 March 28th 08 03:42 PM
linking two workbooks with ODBC & the Excel Driver Blinkburg Excel Programming 0 March 22nd 05 04:59 PM
xl odbc driver, Excel 2003 johnny_2005 Setting up and Configuration of Excel 0 February 15th 05 10:08 PM
which odbc excel driver is the best? andre Excel Programming 2 June 3rd 04 06:36 PM
[ODBC Excel Driver] Too few parameters. Expected 1. Dave - A1 Excel Programming 0 September 4th 03 03:56 PM


All times are GMT +1. The time now is 11:27 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"