1

clarification
David thinks this is a duplicate. I'm aware of that other question, I'm referring to the answer there. It just doesn't solve my problem; for instance I don't see the CreateDatabase property in the Object Inspector.

I am acquainted with Delphi, but this is the first time I need a database in a project. Using Delphi XE8.

In this answer to another question I found a script to create a database, which I used verbatim:

SET SQL DIALECT 3;
SET NAMES UTF8;
SET CLIENTLIB 'C:\fb25\bin\fbclient.dll';
CREATE DATABASE 'D:\MyProject.fdb'
  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^

But I'm having problems with FDConnection1. In its parameters I entered a database filename, but I don't see the CreateDatabase property said answer mentions. When I execute

FDScript1.ExecuteAll;

nothing happens.

How can I create my database? And where can I set CreateDatabase=yes?

edit 1: What I tried
I created a VCL application with a TFDScript (FDScript1) and a TFDConnection (FDConnection1). I entered the above script in the FDScript1.SQLScripts property and assigned FDConnection1 to its Connection property.
For FDConnection1 I set DriverName to "FB", entered a ConnectionName and entered a filename (full path) in params.database.

David points out that my assumption that CreateDatabase would be a Property is wrong. Should this then be in the script? (It does already say "CREATE DATABASE".)

6
  • Possible duplicate of Creating a database in Firebird using FireDac (Delphi) Commented Dec 1, 2016 at 8:10
  • This is a slam dunk dupe of the question you linked to. Read the answer. Nowhere does it suggest you use TFDConnection to execute SQL. So read the answer carefully. Follow the links. Read them. Do what it says. You need to pay close attention to what is written. Commented Dec 1, 2016 at 8:19
  • The answer at the dupe doesn't talk about the Object Inspector, unless I mis-read it. Can you point out the section where it describes setting properties of TFDConnection in the Object Inspector. What I see is information about using TFDScript. If you have information about how you have setup the Connection property of your TFDScript please share it. If the question is asking to solve your specific attempt to follow the instructions, provide exact details of your steps so far. Commented Dec 1, 2016 at 9:10
  • Parameters go in Params I think: docwiki.embarcadero.com/Libraries/en/… Commented Dec 1, 2016 at 9:55
  • @David: Yes, these params seem to be a TStringList, though you can also assign the values through the Object Inspector, or as object members in code: FDConnection1.Params.Database := 'D:\myproject\dakota2.fdb';. Thanks for your time. Commented Dec 1, 2016 at 10:27

1 Answer 1

0

The CreateDatabase connection definition parameter has been replaced by OpenMode parameter. I'd would suggest setting it to OpenOrCreate in your case (which creates database if doesn't exist, or uses the existing one):

...
FDConnection1.Params.Add('OpenMode=OpenOrCreate');
FDConnection1.Connected := True;

For FireDAC shipped with Delphi XE7 or below, use the mentioned CreateDatabase parameter.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.