If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > Drop a tab Sheet from an Excel worksheet with ADO

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-02-02, 18:30
nicolasdemarco nicolasdemarco is offline
Registered User
 
Join Date: Aug 2002
Location: Argentina
Posts: 2
Drop a tab Sheet from an Excel worksheet with ADO

First: sorry for my English.
I was filled an Excel worksheet with OLEDB (ADO). I first open an Empty worksheet with a single sheet. Then I create an other sheet with the command "CREATE TABLE...". Then I fill the new table (sheet) by multiple command "INSERT INTO". Tha'ts all OK.

Of course I cannot create
But I cannot delete the original sheet with a command "DROP TABLE". I first ask for the tables that shuch database has, but when I execute the command "DROP TABLE Sheet1" (for example) the interfase respond: "The table does not exists".

The code I wrote (Delphi) is:
List := TStringList.Create;
Conection.GetTableNames(List, False);

for i := 0 to List.Count - 1 do begin
if (Trim(List[i]) <> MySheetName) then
begin
ComandADO.CommandText := 'DROP TABLE [' +
StringReplace(Trim(List[i]), '$', '', [rfReplaceAll]) + ']';
ComandADO.Execute;
end;
end;
List.Free;
I tried without the "[", "]" and does not work.

I also try with a simple ADOQUERY, but the result is the same.

Tanks
Nicolas
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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