Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default using ADO for database in sheet

hi,

Despite MS said that ExcdlADO should be reference in the following format:

strSQL = "SELECT * FROM [Sheet1$B1:C20]"

But you should also try:

strSQL = "SELECT * FROM [DATABASE$B1:C20]"

where DATABASE is the name of Sheet9. I don't know how I have programmed,
(Using Jet database), but I couldn't get the 1st scenario working, and got
the following Run-time error:

Run-time error '-2147217865 (80040e37)':
The Microsoft Jet Database could not find the object 'Sheet1$B1:C20'. Make
usre the object exists and that you spell its name and the path correctly.

If someone know about what cause this behaviour, please let me know.

Regards
Augustus

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 593
Default using ADO for database in sheet

"augustus" wrote ...

Despite MS said that ExcdlADO should be reference in the following format:

strSQL = "SELECT * FROM [Sheet1$B1:C20]"

But you should also try:

strSQL = "SELECT * FROM [DATABASE$B1:C20]"

where DATABASE is the name of Sheet9. I don't know how I have programmed,
(Using Jet database), but I couldn't get the 1st scenario working, and got
the following Run-time error:

Run-time error '-2147217865 (80040e37)':
The Microsoft Jet Database could not find the object 'Sheet1$B1:C20'. Make
usre the object exists and that you spell its name and the path correctly.


I'm a bit confused here. Is you worksheet named DATABASE, Sheet1 or
Sheet9? It can't be more than one. I'll assume it is named DATABASE.

Which provider/driver are you using? If you are using the odbc driver,
success may depend of the way the data is organized. For example, say
your UsedRange, being the part of the sheet that contains or has
contained data and therefore determines the extents of the 'table' for
the sheet, is A1:A3. If you then queried the sheet using

SELECT * FROM [DATABASE$B1:C20];

the specified Range is outside of the table extents and the odbc
driver throws an exception; the description I get via the OLE DB
provider for odbc is:

[Microsoft][ODBC Excel Driver] This table contains cells that are
outside the range of cells defined in this spreadsheet.

In the same circumstance using the OLE DB provider for Jet 4.0, I get
no error and two columns, F1 and F2 with three null rows i.e. the
number of columns corresponds to the number of columns requested and
the number of rows is consistent with the UsedRange.

In conclusion, the Jet 4.0 provider is more flexible and can be useful
for querying within or outside of the usual bounds of a sheet's
'table'.

Jamie.

--
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default using ADO for database in sheet

Sorry for the confusion, sheet9 should be sheet1, and DATABASE is the name
for Sheet1.
I remember I read somewhere that you cannot use the name of a sheet if using
Jet4 for Excel. I tested it out, which is true. But when I code the
application that I am doing now, I have to use the name and not sheet1.
To clarify, Sheet1 = DATABASE , when I view them inside Visual Basic Editor.

Thanks
Augustus

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default using ADO for database in sheet


your test leads to wrong conclusions.

you MUST reference the sheetname else you'll retrieve the data from the
sheet that was active when the file was saved.

that just might to unexpected results <g

also your clarificaiton is again "multiinterpretable"

sheet1=database... VERY logical.. or do you mean to say
the first sheet is named "Database"
then nineth sheet is names "Sheet1" ??




--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


augustus wrote :

Sorry for the confusion, sheet9 should be sheet1, and DATABASE is the
name for Sheet1.
I remember I read somewhere that you cannot use the name of a sheet
if using Jet4 for Excel. I tested it out, which is true. But when I
code the application that I am doing now, I have to use the name and
not sheet1. To clarify, Sheet1 = DATABASE , when I view them inside
Visual Basic Editor.

Thanks
Augustus

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default using ADO for database in sheet

(Say you name your Sheet1 to Database, but when you open up VBE, under
Project Explorer, you see it as "Sheet1 (Database)".

Also, I realised something too, the reason why the test code work is because
I didn't name any of the sheet.


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default using ADO for database in sheet

dont confuse the .Codename with the .Name property

when you use Ado you can only use the .Name
(which is the one you see on the tab in Excel
and see inside the brackets in VB project explorer

--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam

?B?YXVndXN0dXM=?= wrote in message
:

(Say you name your Sheet1 to Database, but when you open up VBE, under
Project Explorer, you see it as "Sheet1 (Database)".

Also, I realised something too, the reason why the test code work is
because I didn't name any of the sheet.


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 593
Default using ADO for database in sheet

"keepITcool" wrote ...

your test leads to wrong conclusions.

you MUST reference the sheetname else you'll retrieve the data from the
sheet that was active when the file was saved.


keepITcool,
Sorry, your test also leads to wrong conclusions <g.

If you omit the sheet name e.g.

SELECT * FROM [A:A]

the worksheet queried will be the first i.e.
ThisWorkbook.Worksheets(1), even if it is hidden.

You can also omit the sheet name if you are using a workbook-level
defined Name, of course <g.

Jamie.

--
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
Time sheet database Oldjay Excel Discussion (Misc queries) 0 October 10th 06 04:54 PM
Database (or the like) from Excel Sheet Ratedr Excel Discussion (Misc queries) 3 September 21st 06 09:52 PM
How to include data on the same sheet some in database some not Edify Excel Worksheet Functions 0 May 18th 06 09:28 PM
Selecting data from database sheet Duane Excel Discussion (Misc queries) 0 May 8th 06 10:30 PM
copy database to another sheet lexitollah via OfficeKB.com Excel Worksheet Functions 2 June 30th 05 03:40 PM


All times are GMT +1. The time now is 02:10 AM.

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"