Skip to content

FbConnection.CreateDatabase fails with a letter outside the scope of a-z eg. ö (on embedded firebird) #1019

@Rand-Random

Description

@Rand-Random

I have have the following code

using System.Text;
using FirebirdSql.Data.FirebirdClient;

//this line causes, the creation of the database to work
//the difference is that will FirebirdSql.Data.Common.Encoding2 to be ANSI while System.Text.Encoding.Default to be UTF8
//without this line both are UTF8
//Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);

Directory.CreateDirectory("Föö");
var dbPath = Path.GetFullPath("Föö\\MyFooDatabase.fdb");

//go up to solution dir
var fbClientDll = Path.GetFullPath("..\\..\\..\\..\\Fb4xEmbedded\\fbclient.dll");
var conString = GetEmbeddedConnectionString(fbClientDll, dbPath);

FbConnection.CreateDatabase(conString, 32768, false, true);

static string GetEmbeddedConnectionString(string fbPath, string dbPath)
{
    var stringBuilder = new FbConnectionStringBuilder
    {
        Database = dbPath,
        ClientLibrary = fbPath,
        ServerType = FbServerType.Embedded,
        UserID = "sysdba",
        Password = "sysdba",
    };

    return stringBuilder.ToString();
}

I also created a github repository for you to simply download and run.
https://github.com/Rand-Random/FbEmbeddedCreateDataBase

This code will fail with the error message:

FirebirdSql.Data.FirebirdClient.FbException
HResult=0x80004005
Message=I/O error during "CreateFile (create)" operation for file "C:\USERS\xxx\SOURCE\REPOS\CONSOLEAPP92\CONSOLEAPP92\BIN\DEBUG\NET6.0\Föö\MYFOODATABASE.FDB"
Error while trying to create file
Source=FirebirdSql.Data.FirebirdClient
StackTrace:
at FirebirdSql.Data.FirebirdClient.FbConnection.CreateDatabase(String connectionString, Int32 pageSize, Boolean forcedWrites, Boolean overwrite)
at Program.

$(String[] args) in C:\Users\xxx\source\repos\ConsoleApp92\ConsoleApp92\Program.cs:line 18

This exception was originally thrown at this call stack:
FirebirdSql.Data.Client.Native.FesDatabase.ProcessStatusVector(System.IntPtr[])
FirebirdSql.Data.Client.Native.FesDatabase.CreateDatabase(FirebirdSql.Data.Common.DatabaseParameterBufferBase, string, byte[])
FirebirdSql.Data.FirebirdClient.FbConnectionInternal.CreateDatabase(int, bool, bool)
FirebirdSql.Data.FirebirdClient.FbConnection.CreateDatabase(string, int, bool, bool)

Inner Exception 1:
IscException: I/O error during "CreateFile (create)" operation for file "C:\USERS\xxx\SOURCE\REPOS\CONSOLEAPP92\CONSOLEAPP92\BIN\DEBUG\NET6.0\Föö\MYFOODATABASE.FDB"
Error while trying to create file

It only will fail with Embedded Server and you need to use .net 5 or .net 6, those .net versions that have Encoding.Default defined as UTF8 and not ANSI as .Net Framework did.

Firebird is Version 4.0.1.2692.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions