ADO方式下判断数据表是否存在


//
//------------------------------------------------------------------------------
Function TableExist( pAdoCmd: TADOCOMMAND; pcTable : string ) : boolean ; overload ;
var cError : string ;
begin
ADO_COMMAND_EXEC( pAdoCmd, 'Select top 1 from ' + pcTable , cError );
result := ( cError = '' );
end ;

函数二:
// ------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
Function TableExist( pConn:TADOConnection; pcTable : string ) : boolean ; overload ;
var tmpFldList : TStrings ;
nLoop : integer ;
begin
Result := False ;
tmpFldList := TStringList.Create ;
pConn.GetTableNames( tmpFldList, True ); // 包含系统表
for nLoop := 0 to tmpFldList.Count - 1 do
begin
if uppercase( tmpFldList[nLoop] ) = uppercase( pcTable ) then
begin
Result := True ;
break ;
end;
end;
tmpFldList.Free ;
end;

(出处:DelphiFans.com)

posted on 2007-01-31 12:29  martian6125  阅读(232)  评论(0编辑  收藏  举报