Page 1 of 1
GetTableNames returning system table for Access
Posted: Wed 16 Apr 2014 17:07
by arusoft
Are are using latest uniDac universal components.
For ms access tuniConnection function GetTableNames is returning system table names like MSysNavPaneGroupCategories,MSysNavPaneGroups,MSysNavPaneGroupToObjects..etc
Here is sample code.
uniConnectio1.ProviderName := 'ACCESS';
uniConnectio1.LoginPrompt := false;
uniConnectio1.Database := opendialog.filename;
uniConnectio1.Connected := true;
if uniConnectio1.connected then
uniConnectio1.GetTableNames( StringList1,False );
Please help.
Thanks.
Re: GetTableNames returning system table for Access
Posted: Thu 17 Apr 2014 10:08
by AlexP
Hello,
The AllTables parameter in the GetTableNames makes difference for those databases, in which different schemes are supported within one DB. To retrieve only user tables, you can use the TuniMetaData component.
Code: Select all
program Project11;
{$APPTYPE CONSOLE}
uses
SysUtils, Uni, AccessUniProvider;
var
UniConnection: TUniConnection;
UniMetaData: TUniMetaData;
begin
UniConnection := TUniConnection.Create(nil);
try
UniConnection.ConnectString := 'LoginPrompt=False;ProviderName=Access;Data Source=d:\BD.accdb';
UniConnection.Connect;
UniMetaData := TUniMetaData.Create(nil);
try
UniMetaData.Connection := UniConnection;
UniMetaData.MetaDataKind := 'Tables';
UniMetaData.Restrictions.Values['TABLE_TYPE'] := 'SYSTEM TABLE';
UniMetaData.Open;
while not UniMetaData.Eof do begin
WriteLn(UniMetaData.FieldByName('TABLE_NAME').AsString);
UniMetaData.Next;
end;
finally
UniMetaData.Free;
end;
finally
UniConnection.Free;
readLn;
end;
end.
P.S. As Restrictions parameters, you can also specify TABLE, SYSTEM TABLE, VIEW, to retrieve corresponding objects.
Re: GetTableNames returning system table for Access
Posted: Mon 21 Apr 2014 14:25
by arusoft
Alex,
I did used AllTables as false in GetTableNames . And I am still getting this issue.
uniConnectio1.GetTableNames( StringList1,False );
Are you suggesting we don't use as above and instead use TuniMetaData ?
Thanks
Re: GetTableNames returning system table for Access
Posted: Mon 21 Apr 2014 16:16
by arusoft
Alex,
This worked for me.
UniMetaData.Restrictions.Add('TABLE_TYPE=TABLE');
Still wondering why this did not worked
uniConnectio1.GetTableNames( StringList1,False );
Thanks.
Re: GetTableNames returning system table for Access
Posted: Tue 22 Apr 2014 10:07
by AlexP
As I wrote you earlier, the AllTables parameter makes sense for those databases only, in which schemes exist, in MS Access this parameter is ignored. To retrieve database objects, you should use the UniMetaData component, as it is shown in the previous sample.
Re: GetTableNames returning system table for Access
Posted: Mon 28 Apr 2014 13:38
by arusoft
Thanks Alex for further clarification. That definitely makes sense.
Thank You.