I am using Delphi 10.4, UniDAC 8.3.2, FirebirdSQL 3.0.7 Win32
I can successfully create databases using UniDAC if FirebirdSQL is running as a server. When I try the same using embedded connection, I get below error:
Code: Select all
Unable to complete network request to host "xnet://Global\FIREBIRD"
Identical code can create a database successfully if there ls a server service running. I am sharing my database create function below.
Code: Select all
function CreateFdbDatabase(const DBName, Server, DatabaseUser, DatabaseUserPassword, FBClientDll: string; const Codepage: string = 'WIN1254'; const Port: Word = 3050): Boolean;
var
DB: TUniconnection;
Script: TUniScript;
begin
DB := nil;
Script := nil;
try
DB := TUniConnection.Create(nil);
DB.ProviderName := TInterBaseUniProvider.GetProviderName();
DB.Server := Server;
DB.Port := Port;
DB.SpecificOptions.Values['ClientLibrary'] := FBClientDll;
if DB.Server.IsEmpty then // When embedded, this is empty
DB.SpecificOptions.Values['Protocol'] := 'Local'; // We must switch to Local for embedded
Script := TUniScript.Create(nil);
Script.OnError := TMyClass.ScriptError;
Script.Connection := DB;
Script.NoPreconnect := True;
if not Server.IsEmpty then
Script.SQL.Add('create database ' + QuotedStr(Server + '/' + Port.ToString() + ':' + DBName))
else
Script.SQL.Add('create database ' + QuotedStr(DBName));
Script.SQL.Add('USER ' + QuotedStr(DatabaseUser) + ' PASSWORD ' + QuotedStr(DatabaseUserPassword));
Script.SQL.Add('PAGE_SIZE 16384');
if not Codepage.IsEmpty then
Script.SQL.Add('DEFAULT CHARACTER SET ' + Codepage);
try
Script.Execute();
except
on E: Exception do
begin
if Assigned(FirebirdSQLLog) then FirebirdSQLLog.LogError('Script Error: ' + E.Message);
Exit(False);
end;
end;
Result := True;
finally
Script.Free();
DB.Free();
end;
end;
I would like to learn if there is anything I am overlooking at for the embedded database creation. I appreciate any help.
Thanks & Regards,
Ertan