Mega Search
23.2 Million


Sign Up

Make a donation  
FireDac FDScript to create database in MSSQL help  
News Group: embarcadero.public.delphi.database.firedac

I am using XE6 Update 1 and trying to understand how to create a
database with tables in MSSQL. I tried compiling the sample project
FDExecutor in the hope of understanding how to do this in code, but
unfortunately it gave a lot of errors. 

I would like to use FDScript to create the database in MSSQL and I was
wondering if anyone can help in explaining how to do this in code. I
do have an exported .sql file from MSSQL and I think I can load this
into FDScript. Will that be enough to create the database or are there
other factors to take into account, like the server name and password?
Thanks in advance. 

Andy

Vote for best question.
Score: 0  # Vote:  0
Date Posted: 10-Nov-2014, at 6:16 PM EST
From: Andy Colmes
 
Re: FireDac FDScript to create database in MSSQL help  
News Group: embarcadero.public.delphi.database.firedac
> The code snippet worked as expected. How would I check for status
> events if the script works or fails? 

http://docwiki.embarcadero.com/Libraries/XE7/en/FireDAC.Comp.Script.TFDScriptOptions.BreakOnError
http://docwiki.embarcadero.com/Libraries/XE7/en/FireDAC.Comp.Script.TFDScript.TotalErrors
http://docwiki.embarcadero.com/Libraries/XE7/en/FireDAC.Comp.Script.TFDScript.OnError

-- 
With best regards,
Dmitry Arefiev / FireDAC Architect

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 16-Nov-2014, at 11:53 PM EST
From: Dmitry Arefiev
 
Re: FireDac FDScript to create database in MSSQL help  
News Group: embarcadero.public.delphi.database.firedac
Hi Dmitry, 

The code snippet worked as expected. How would I check for status
events if the script works or fails? 

Thanks again Dmitry.

Andy

On Mon, 10 Nov 2014 21:47:11 -0800, Dmitry Arefiev <> wrote:

>{code}FDConnection1.Params.Clear;
>FDConnection1.Params.Add('DriverID=MSSQL');
>FDConnection1.Params.Add('Server=127.0.0.1');
>FDConnection1.Params.Add('Database=master');
>FDConnection1.Params.Add('User_Name=sa');
>FDConnection1.Params.Add('Password=....');
>FDConnection1.Connected := True;
>
>FDScript1.Connection := FDConnection1;
>FDScript1.ScriptOptions.CommandSeparator := 'go';
>FDScript1.ExecuteFile('c:\create.sql');{code}

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 16-Nov-2014, at 4:58 PM EST
From: Andy Colmes
 
Re: FireDac FDScript to create database in MSSQL help  
News Group: embarcadero.public.delphi.database.firedac
Hi Dimitry, 

Thank you very much. I will give it a try. 

Andy

On Mon, 10 Nov 2014 21:47:11 -0800, Dmitry Arefiev <> wrote:

>{code}FDConnection1.Params.Clear;
>FDConnection1.Params.Add('DriverID=MSSQL');
>FDConnection1.Params.Add('Server=127.0.0.1');
>FDConnection1.Params.Add('Database=master');
>FDConnection1.Params.Add('User_Name=sa');
>FDConnection1.Params.Add('Password=....');
>FDConnection1.Connected := True;
>
>FDScript1.Connection := FDConnection1;
>FDScript1.ScriptOptions.CommandSeparator := 'go';
>FDScript1.ExecuteFile('c:\create.sql');{code}

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 11-Nov-2014, at 6:55 AM EST
From: Andy Colmes
 
Re: FireDac FDScript to create database in MSSQL help  
News Group: embarcadero.public.delphi.database.firedac
{code}FDConnection1.Params.Clear;
FDConnection1.Params.Add('DriverID=MSSQL');
FDConnection1.Params.Add('Server=127.0.0.1');
FDConnection1.Params.Add('Database=master');
FDConnection1.Params.Add('User_Name=sa');
FDConnection1.Params.Add('Password=....');
FDConnection1.Connected := True;

FDScript1.Connection := FDConnection1;
FDScript1.ScriptOptions.CommandSeparator := 'go';
FDScript1.ExecuteFile('c:\create.sql');{code}

-- 
With best regards,
Dmitry Arefiev / FireDAC Architect

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 10-Nov-2014, at 9:47 PM EST
From: Dmitry Arefiev