问题描述
我最近从AnyDac更改为FireDac(8.0.5.3365).我们正在运行Delphi 2006.
I recently changed from AnyDac to FireDac (8.0.5.3365). We're running Delphi 2006.
当我使用此组件的AnyDac版本时,我可以通过执行以下操作来创建新数据库.
When I was using the AnyDac version of this component I could create a new database by doing the following..
设置我的连接
fConnection.LoginPrompt := false;
fConnection.ResourceOptions.SilentMode := true;
fConnection.Params.Clear;
fConnection.Params.Add(Format('DriverID=%s', ['IB']));
fConnection.Params.Add(Format('Database=%s', [fConnectionInfo.xDatabase]));
fConnection.Params.Add(Format('CharacterSet=%s', ['UTF8']));
fConnection.Params.Add(Format('user_name=%s', [fConnectionInfo.xUserName]));
fConnection.Params.Add(Format('password=%s', [fConnectionInfo.xPassword]));
fConnection.Params.Add(Format('ExtendedMetadata=%s', ['True']));
fConnection.Params.Add(Format('CreateDatabase=%s', ['Yes']));
fConnection.Params.Add(Format('Protocol=%s', ['Local']))
//database path = C:\Users\LoginName\AppData\Local\AppName\TestDB.FDB
打开和关闭连接
fConnection.Open;
fConnection.Close;
然后我可以在现有数据库上运行我的创建表sql脚本.
And then I could run my create table sql scripts on the existing database.
但是现在,当我使用FireDac版本执行此操作时,打开"命令会引发fbe_unavailable错误,就好像我没有指定CreateDatabase参数一样.
But now when I do this with the FireDac version, the Open command raises the fbe_unavailable error as if I didn't specify the CreateDatabase parameter.
我应该以不同的方式这样做吗?
Should I be doing this a different way?
感谢您的时间.
科里.
推荐答案
您在这里有完整的示例 http://docwiki.embarcadero.com/RADStudio/Rio/en/Executing_SQL_Scripts_%28FireDAC%29
You have a full example here http://docwiki.embarcadero.com/RADStudio/Rio/en/Executing_SQL_Scripts_%28FireDAC%29
例如,以下Firebird脚本创建一个数据库,并且可以使用TFDScript执行:
For example, the following Firebird script creates a database, and can be executed using TFDScript:
SET SQL DIALECT 3;
SET NAMES UTF8;
SET CLIENTLIB 'C:\fb25\bin\fbclient.dll';
CREATE DATABASE 'E:\Test2.ib'
USER 'sysdba' PASSWORD 'masterkey'
PAGE_SIZE 16384
DEFAULT CHARACTER SET NONE;
SET TERM ^ ;
CREATE PROCEDURE MY_PROC RETURNS (aParam INTEGER) AS
BEGIN
aParam = 10;
END^
您应该使用CreateDatabase = Yes连接定义参数除其他必需参数外: http://docwiki.embarcadero.com/RADStudio/Rio/en/Connect_to_Firebird_ (FireDAC)
You should use CreateDatabase=Yes connection definition parameteradditionally to other required parameters:http://docwiki.embarcadero.com/RADStudio/Rio/en/Connect_to_Firebird_(FireDAC)
这篇关于使用FireDac(Delphi)在Firebird中创建数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!