Problem with DbProvider

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with DbProvider

dtarczynski
Hello.
I have problems with that code (when I setup DbProvider).
When I wrote for example:

DatabaseTarget target = new DatabaseTarget();
target.DBProvider = "System.Data.SqlClient.SqlConnection";

Then getting Exception:

{"Object reference not set to an instance of an object."}
StackTrace = "   at NLog.Targets.DatabaseTarget.get_DBProvider()"

But when I wrote:

DatabaseTarget target = new DatabaseTarget();
target.DBProvider = "mssql";

Everything is allright. Im suprised this because this should be equal. Why isn't?
I wrote this example because I tried to setup other DbProvider (Firebird) manually and I done this for tests with Sql Server at first.

I hope this clear :) Please help.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with DbProvider

Jarek Kowalski
Administrator
"System.Data.SqlClient.SqlConnection"

should be replaced with a fully qualified type name in this case (including all the details of the assembly)

"System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"

mssql is just a shortcut for this. Feel free to change the code of DatabaseTarget by adding another shortcut for firebird and post your changes to the list so that others can benefit from this one.

Jarek
NLog Blog