jackson_1
14 years agoFrequent Contributor
how to verify a table if exist in access database in delphi script
hi all,
in my testing project. i need a function to verify the special table if created in access database, and i use the following script to verify it, but the result always is false. so i want to know there is any issue in my script?
-----------------------------------------------
in my testing project. i need a function to verify the special table if created in access database, and i use the following script to verify it, but the result always is false. so i want to know there is any issue in my script?
-----------------------------------------------
function ValidateSpecialTable(aStrDBPath,aStrTableName): boolean;
var
ADOReSchema,ADOCnn;
begin
ADOCnn: = Sys.OleObject('ADODB.Connection');
ADOCnn.ConnectionString: = 'Provider=Microsoft.ACE.OLEDB.12.0;' +'Data Source=' + aStrDBPath;
ADOCnn.Open();
ADOReSchema: = ADOCnn.OpenSchema(20);
ADOReSchema.MoveFirst;
repeat
begin
if ((ADOReSchema[('TABLE_TYPE')]) = 'TABLE' ) and ((ADOReSchema[('TABLE_NAME')]) = aStrTableName) then
begin
result: = true;
exit;
end
else
result: =false;
end;
ADOReSchema.MoveNext;
until ADOReSchema.Eof
end;