FIREDAC TFDCONNECTION连接ORACLE

FIREDAC TFDCONNECTION连接ORACLE

1)安装OCI

2)如图设置参数

3)连接代码:

procedure TfrmDB.ConnectDB;
begin
FDMoniFlatFileClientLink1.FileName := ExtractFilePath(Application.ExeName) + 'sql'+ FormatDateTime('yyyymmdd', now)+'.txt';
con.Close;
con.Params.Clear;
con.Params.Add('DriverID=' + DatabaseParams.driveId);
con.Params.Add('Server=' + DatabaseParams.ip);
con.Params.Add('Database=' + DatabaseParams.database);
con.Params.Add('User_Name=' + DatabaseParams.user);
con.Params.Add('Password=' + DatabaseParams.password);
if SameText(DatabaseParams.driveId, 'MySQL') then
con.Params.Add('CharacterSet=gb2312');
con.Params.Add('MonitorBy=FlatFile');
try
con.Connected := True;
Log.WriteLog(DatabaseParams.database + ' database connect ok');
except
on e: Exception do
Log.WriteLog('TfrmDB.ConnectDB ' + e.Message);
end;
end;

posted @ 2017-01-10 10:52  delphi中间件  阅读(2261)  评论(0编辑  收藏  举报