Search code examples
c#odbcfirebirdfirebird-3.0

Firebird ODBC Driver not load UDF dll


My DB have a lot of procedures that uses functions from rfunc.dll, but when I try to uses ODBC Driver connection on C# the UDF functions doesn't load

Here how I'm doing the connection

public OdbcConnection Conecta(string serverName, string databaseName, string userName, string password, string DriverName)
{
    
    string connectionString = $"User={userName};Password={password};Database={databaseName};DataSource={serverName};Driver={DriverName};";

    // Criar a conexão
    OdbcConnection connection = new OdbcConnection(connectionString);
    try
    {
        // Abrir a conexão
        connection.Open();

        // A conexão foi aberta com sucesso, você pode executar consultas aqui

        return connection;
    }
    catch (Exception ex)
    {
        // Tratar exceção, se necessário
        Console.WriteLine("Erro ao conectar-se ao banco de dados: " + ex.Message);
        //Console.Beep();
        return null;
    }
}
 OdbcConnection FBconnection = new Database().Conecta("127.0.0.1:3050", "My\\Database\\path\\.fdb", "SYSDBA", "masterkey", "Firebird/InterBase(r) driver");

Its all working but the rfunc functions is not working, if someone have any idea?

Firebird 3.0 Firebird ODBC 2.0.5


Solution

  • As user246821 tries to indicate in their comment, the Firebird ODBC driver has no DataSource property. See the ODBC driver documentation for a list of properties. Specifically, you need to use DBNAME or DATABASE with the full connection URL as expected by fbclient.dll.

    In your case, you need to specify Database=inet://{serverName}/{databaseName} instead of Database={databaseName};DataSource={serverName}.

    Alternatively, you could specify the legacy URL format Database={serverName}:{databaseName}, but then you need to change your calling code to .Conecta("127.0.0.1/3050", ..., or simply .Conecta("127.0.0.1", ... as 3050 is the default anyway.

    The problem you have is probably that you're current solution loads Firebird Embedded without access to the UDFs, instead of connecting through Firebird server with access to UDFs.