Firebird .NET provider and ASP.NET
I have no problems setting up a regular (Windows Forms or Console) project in C# to use Firebird's .NET data provider.
However, whenever I try to use the same provider in ASP.NET I do the following:
- Copy the DLL to the project to keep it under version control
- Add the reference to the project
- Create an entry in
<connectionStrings/>
tag for my connection. - Try to use the entry to connect to Firebird
Here is the entry example:
&l开发者_如何学运维t;connectionStrings>
<add
name="cstringdbname"
connectionString="User=SYSDBA;Password=MY_PASS;Database=/opt/interbase/data/mydbname;Server=MyHostName; Connection lifetime=15;Pooling=true"
providerName="Firebird"/>
</connectionStrings>
I tried with different stuff in providerName
attribute. Nothing seems to work.
My problem is in step #4. Whenever I try connecting to the Database with a SqlDataSource component, the connection attempts to use SQLServer data provider instead of Firebird's, and I get an error.
My question: is there anything else I need to do in order to make ASP.NET to load, use, acknwoledges the existance of my Firebird provider?
I too tried this in a past project and didn't get it to work. However, I only found the connection string to matter, so I moved the setting to the appSettings section. Once you do this, you can use the same connection settings that you used for your WinApp projects.
This is what I did to get it to work:
- Changed the web config adding these entries:
First, a new DBProviderFactory under configuration
tag:
<system.data>
<DbProviderFactories>
<remove invariant="FirebirdSql.Data.FirebirdClient"/>
<add
name="Firebird Data Provider"
invariant="FirebirdSql.Data.FirebirdClient" description="Firebird"
type="FirebirdSql.Data.FirebirdClient.FirebirdClientFactory, FirebirdSql.Data.FirebirdClient"
/>
</DbProviderFactories>
</system.data>
Second, my connection string entry looks like this:
<connectionStrings>
<add
name="rshkdb"
connectionString="User=u;Password=p;Database=/mydb;Server=X.X.X.X; Connection lifetime=15;Pooling=true"
/>
</connectionStrings>
- Added the Firebird's client DLL to the project's references using Copy Local option to true. This is very important, otherwise, ASP.NET won't find the library at runtime (only at compile time).
精彩评论