3

I want to test dapper micro orm with firebird db and I'm struggle with access to firebird.

Firebird server is up and running, database is populated with some dummy data, and it is stored in c:\mydatabases\test.fdb

Connection string is

<add name="testDatabase" connectionString="User=SYSDBA;
           Password=XXX; Database=c:\mydatabases\test.fdb; 
           Data Source=127.0.0.1;" />

Inside my repository I'm accessing to the db using IDbConnection

private IDbConnection db = 
     new SqlConnection(ConfigurationManager.ConnectionStrings["testDatabase"]
         .ConnectionString);

but when I'm trying to access data exception is thrown

A first chance exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll

Additional information: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

Is it possible to use IDbConnection with firebird and if it's not what do you suggest.

Thanks

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
user2783193
  • 992
  • 1
  • 12
  • 37

2 Answers2

5

You should use FBConnection instead.

Download and reference FirebirdSql.Data.Firebird and instead of

IDbConnection db = new SqlConnection...

use this

IDbConnection dbcon = new FbConnection(connectionString); 
BobRock
  • 3,477
  • 3
  • 31
  • 48
3

The SqlConnection is class specific for SQL Server. What you need to do is download ADO.NET provider for Firebird from here. This will give you FirebirdSql.Data.FirebirdClient namespace and FbConnection class which you can use like this:

private IDbConnection db = new FbConnection(ConfigurationManager.ConnectionStrings["testDatabase"].ConnectionString);

You can find more examples on how to use Firebird ADO.NET Provider here.

tpeczek
  • 23,867
  • 3
  • 74
  • 77