user2783193
user2783193

Reputation: 1022

IDbConnection and Firebird

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

Upvotes: 3

Views: 1927

Answers (2)

BobRock
BobRock

Reputation: 3467

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); 

Upvotes: 5

tpeczek
tpeczek

Reputation: 24125

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.

Upvotes: 3

Related Questions