Table - tabelas em cdrom

Top  Previous  Next

Criar um novo projeto com um TTable.

 

Definir databasename e tablename conforme o necessario.

 

Chamar algumas funcoes internas da BDE.

 

Ao chamar estas funcoes, sera gravado no diretorio tal o arquivo nao-sei-o-que.LCK.

 

Pronto, e so copiar este arquivo para o CD-ROM que quando for acessar

as tabelas o BDE ja ira encontrar o LCK e ficara na dele.

 

So um detalhe : Tive que colocar minha_tabela.readonly := true antes de

abri-las no meu projeto final. (afinal, sera so leitura mesmo ...)

nao precisei mudar netdir, privatedir nada disso !!

 

Comecei um novo projeto, nele tem um campo edit (edit1) e um Tdatabase

(NAO e ttable) e um botao (Tbuton) Aqui vai todo o codigo :

 

------------------------------------------------------

unit Unit1;

 

interface

 

uses

  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,

Dialogs,

  Filectrl,

{$IFDEF WIN32}

    BDE, StdCtrls, DBTables;

  {$ELSE}

    DbiProcs, DbiTypes, DbiErrs;

  {$ENDIF }

 

type

  TForm1 = class(TForm)

    Button1: TButton;

    Edit1: TEdit;

    Database1: TDatabase;

    Label1: TLabel;

    procedure Button1Click(Sender: TObject);

  private

    { Private declarations }

  public

    { Public declarations }

    function ChkPath : Boolean;

  end;

 

var

  Form1: TForm1;

 

implementation

 

function TForm1.ChkPath : Boolean;

var

  s : array[0..100of char;

begin

  If DirectoryExists(Edit1.Text) then begin

    DataBase1.DatabaseName:= 'DADOS';

    DataBase1.DriverName:= 'Standard';

    DataBase1.LoginPrompt:= false;

    DataBase1.Connected := False;

    DataBase1.Params.Add('Path=' + Edit1.Text);

    DataBase1.Connected := TRUE;

    Result := TRUE;

  end

  else begin

    StrPCopy(s,'Directory : ' + Edit1.text + ' Does Not Exist');

    Application.MessageBox(s, 'Error!', MB_ICONSTOP);

    Result := FALSE;

  end;

end;

 

{$R *.DFM}

 

procedure TForm1.Button1Click(Sender: TObject);

begin

  if ChkPath then

    Check(DbiAcqPersistTableLock(Database1.Handle,

               'PARADOX.DRO','PARADOX'));

end;

 

end.