X
xy_c
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.Button1Click(Sender: TObject);
var
adoconnection:Tadoconnection;
adoquery:Tadoquery;
mylist:Tstrings;
i:integer;
begin
ADOConnection := TADOConnection.Create(nil);
ADOConnection.LoginPrompt := False;
ADOConnection.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0; Data Source=' + FileN + ';Extended Properties=Excel 8.0';
ADOQuery := TADOQuery.Create(nil);
mylist:=Tstringlist.create;
queryds.dataset:=adoquery;
dbgrid1.DataSource:=queryds;
ADOQuery.Connection := ADOConnection;
ADOConnection.GetTableNames(mylist, false);
for i:=0 to mylist.count-1 do
begin
adoquery.close;
adoquery.SQL.clear;
ADOQuery.SQL.Text := 'Select * from [' + mylist + ']';
ADOQuery.Open;
showmessage(mylist);
end;
ADOQuery.Close;
ADOConnection.Close;
ADOQuery.Free;
ADOConnection.Free;
mylist.free;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
form1.close;
end;
var
adoconnection:Tadoconnection;
adoquery:Tadoquery;
mylist:Tstrings;
i:integer;
begin
ADOConnection := TADOConnection.Create(nil);
ADOConnection.LoginPrompt := False;
ADOConnection.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0; Data Source=' + FileN + ';Extended Properties=Excel 8.0';
ADOQuery := TADOQuery.Create(nil);
mylist:=Tstringlist.create;
queryds.dataset:=adoquery;
dbgrid1.DataSource:=queryds;
ADOQuery.Connection := ADOConnection;
ADOConnection.GetTableNames(mylist, false);
for i:=0 to mylist.count-1 do
begin
adoquery.close;
adoquery.SQL.clear;
ADOQuery.SQL.Text := 'Select * from [' + mylist + ']';
ADOQuery.Open;
showmessage(mylist);
end;
ADOQuery.Close;
ADOConnection.Close;
ADOQuery.Free;
ADOConnection.Free;
mylist.free;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
form1.close;
end;