数据库设置

unit UIBConfigService;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, IBServices;
type
  TFIBConfigService = class(TForm)
    IBConfigService1: TIBConfigService;
    Button1: TButton;
    CheckBox1: TCheckBox;
    CheckBox2: TCheckBox;
    CheckBox3: TCheckBox;
    Edit1: TEdit;
    Edit2: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    CheckBox4: TCheckBox;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FIBConfigService: TFIBConfigService;

implementation

{$R *.dfm}

procedure TFIBConfigService.Button1Click(Sender: TObject);
var
  destSQL,destInterval,result:Integer;
begin
  //检验SQL方言是否为整数
  Val( Edit1.Text,destSQL,result);
  if (result<>0) or( (destSQL<>1) and (destSQL<>3)) then
    begin
      ShowMessage('SQL方言必须为1或3,请重新输入!');
      exit;
    end;

  //检验SQL方言的有效性
  Val( Edit2.Text,destInterval,result);
  if result<>0 then
    begin
      ShowMessage('扫描间隔必须为整数,请重新输入!');
      exit;
    end;

 with IBConfigService1 do
  begin
    ServerName := 'Employee';
    LoginPrompt := False;
    //根据实际情况设置数据库的名称
    DatabaseName := 'G:/malin/employee.gdb';
    Params.Add('user_name=sysdba');
    Params.Add('password=masterkey');
    Active := True;
   try
    //使应用程序可以对数据库的属性进行修改
    SetReadOnly(False);
    //调用Sleep以确保在进行下一项服务之前,上一项服务已经完成
    //确定是否激活映象
    while IsServiceRunning do Sleep(5);
    if CheckBox1.Checked then
          ActivateShadow;

    //确认是否将设置数据库写模式为异步模式
    while IsServiceRunning do Sleep(5);
    if CheckBox2.Checked then
      SetAsyncMode(True);    

    while IsServiceRunning do Sleep(5);
      if CheckBox3.Checked then
      SetReserveSpace(True);

     while IsServiceRunning do Sleep(5);
      SetDBSqlDialect(destSQL);

     while IsServiceRunning do Sleep(5);
      SetSweepInterval(destInterval);

     //确认是否将数据库设置为只读
     while IsServiceRunning do Sleep(5);
     if CheckBox4.Checked then
      SetReadonly(True);

    finally
      Active := False;//关闭数据库
    end;
  end;
end;

end.


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值