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

4

2 回答 2

5

你应该FBConnection改用。

下载和参考FirebirdSql.Data.Firebird,而不是

IDbConnection db = new SqlConnection...

用这个

IDbConnection dbcon = new FbConnection(connectionString); 
于 2013-11-28T13:35:07.857 回答
3

SqlConnection是特定于 SQL Server 的类。您需要做的是从这里下载 Firebird 的 ADO.NET 提供程序。这将为您提供FirebirdSql.Data.FirebirdClient命名空间和FbConnection类,您可以像这样使用它们:

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

您可以在此处找到有关如何使用 Firebird ADO.NET 提供程序的更多示例。

于 2013-11-28T13:34:39.110 回答