PDA

View Full Version : DBIsam & Create Table in RUNTime



FirstLine
یک شنبه 15 آذر 1383, 01:08 صبح
با سلام
آیا در زمان اجرا میتوان یک جدول و بانک DBIsam را ایجاد نمود؟
با تشکر

مهدی کرامتی
دوشنبه 16 آذر 1383, 00:08 صبح
بله. مثال:

unit new;

interface

procedure CreateTables(CreateDatabaseName: string);

implementation

{$IFDEF VER150}
uses Forms, Classes, DB, DBISAMTb, SysUtils, Variants;
{$ENDIF}
{$IFDEF VER140}
uses Forms, Classes, DB, DBISAMTb, SysUtils, Variants;
{$ENDIF}
{$IFDEF VER130}
uses Forms, Classes, DB, DBISAMTb, SysUtils;
{$ENDIF}

procedure CreateTables(CreateDatabaseName: string);
var
TableToCreate: TDBISAMTable;
begin
TableToCreate:=TDBISAMTable.Create(Application);
try
with TableToCreate do
begin
DatabaseName:=CreateDatabaseName;
TableName:='names';
Exclusive:=True;
if (not Exists) then
begin
with FieldDefs do
begin
Clear;
Add('Name',ftString,10);
Add('PicID',ftInteger);
end;
with IndexDefs do
begin
Clear;
Add('','RecordID',[ixPrimary,ixUnique]);
end;
CreateTable(0,1,0,False,'','',4096,512,0);
end;
end;
finally
TableToCreate.Free;
end;
end;

end.

خود DBISAM Additional Tools در DBISAM امکان Reverse Engineer کردن جداول و تبدیل آنها به کد را دارد.