Delphi Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
델파이 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
FreePascal/Lazarus
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
델마당
볼랜드포럼 광고 모집

델파이 Q&A
Delphi Programming Q&A
[2814] [답변] MINWOOJ/ [델파이] ZPDSPF 님...PARADOX DB
이정욱 [ ] 1764 읽음    1998-05-16 16:28
unit Packtbl;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  DB, DBTables, DBiTypes;

type
  TPackTable = class(TTable)
  private
    { Private declarations }
  protected
    { Protected declarations }
    procedure PackError( Error : DBIResult); virtual;
  public
    { Public declarations }
    procedure Pack;
  published
    { Published declarations }
  end;

procedure Register;

implementation

uses DBiProcs, DbiErrs;

procedure TPackTable.Pack;
var OldExclusiveState, OldActiveState : Boolean;
    TableDescription : pCRTblDesc;
    TempResult : DBIResult;
    TempDbHandle : hDBIdb;
    ExtType : TTableType;
    TableNameExt : String;
begin
    OldExclusiveState := Exclusive;
    OldActiveState := Active;
    DisableControls;

    if Active and (not Exclusive) then Close;
    if (not Exclusive) then Exclusive := True;
    if (not Active) then Open;
    TempDbHandle := DBHandle;

    TableNameExt := UpperCase(ExtractFileExt(TableName));
    if TableNameExt = '.DBF' then ExtType := ttdBase else
    if ((TableNameExt = '.DB') or
        (TableNameExt = '')) then ExtType := ttParadox;

    TempResult := DBIERR_NOTSUPPORTED;
    if (TableType = ttdBase) or ((TableType = ttDefault) and (ExtType = ttdBase)) then
    begin
        tempResult := DbiPackTable(DBHandle, Handle, nil, nil, True);
    end else
    if (TableType = ttParadox) or
      ((TableType = ttDefault) and
       (ExtType = ttParadox)) then
    begin
        New(TableDescription);
        FillChar(TableDescription^, SizeOf(TableDescription^), 0);

        with TableDescription^ do
        begin
            bPack := True;
            StrPCopy(szTblName, TableName);
            StrPCopy(szTblType, szParadox);
        end;

        Close;
        TempResult := DbiDoRestructure(TempDBHandle, 1, TableDescription, nil, nil, nil, False);
    end;

    if TempResult <> DBIERR_NONE then PackError(TempResult);

    Close;
    Exclusive := OldExclusiveState;
    Active := OldActiveState;
    EnableControls;
end;


procedure TPackTable.PackError(Error : DBIResult);
var ErrorString : DBIMSG;
begin
    DbiGetErrorString(Error, ErrorString);
    ShowMessage(ErrorString);
end;



procedure Register;
begin
  RegisterComponents('NileX', [TPackTable]);
end;

end.



+ -

관련 글 리스트
2814 [답변] MINWOOJ/ [델파이] ZPDSPF 님...PARADOX DB 이정욱 1764 1998/05/16
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.