UPDATE: Thomas Burkhart sent me a mail telling me that this configuration syntax doesn't work on ms.net 2.0. This is the version which works:
<?xml version="1.0" encoding="iso-8859-1" ?>
<configuration>
<system.data>
<DbProviderFactories>
<add name="Npgsql Data Provider" invariant="Npgsql" support="FF" description=".Net Framework Data Provider for Postgresql Server" type="Npgsql.NpgsqlFactory, Npgsql, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" />
</DbProviderFactories>
</system.data>
</configuration>
Thomas said that "the tags are case sensitive and the must be outside any <applicationSettings>"
Thank you Thomas for your feedback which, for sure will help others to get their configuration up and running. I will check with Mono guys to see why my original configuration worked.
Hi all!
Today I committed an initial support for provider factory to Npgsql2.
This will allow ado.net 2.0 users to work with Npgsql using ado.net generic coding.
In order to use it, you have to add the following xml config in your machine.config or yourapp.exe.config file:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<configuration>
<appsettings>
<system.data>
<dbproviderfactories>
<add name="Npgsql Data Provider" invariant="Npgsql" support="FF" description=".Net Framework Data Provider for Postgresql Server" type="Npgsql.NpgsqlFactory, Npgsql, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7">
</add>
</dbproviderfactories>
</system.data>
</appsettings>
</configuration>
P.S.: Sorry for indentation lacking. I don't know how to add it on blogger :(
Note that this is the full contents of a yourapp.exe.config file. If you are changing the machine.config file, just add the "add name=..." section.
The key elements here are the invariant name which will be used in your application when returning the provider factory. In this case it is defined as "Npgsql". But you can specify whatever you want.
That's it! If everything is ok, you will be able to write some code like that, to connect to postgresql:
using System;
using System.Data;
using System.Data.Common;
public class c
{
public static void Main(String[] args)
{
DbProviderFactory factory = DbProviderFactories.GetFactory("Npgsql");
DbConnection conn = factory.CreateConnection();
conn.ConnectionString = "Server=127.0.0.1;User id=npgsql_tests;password=npgsql_tests;";
conn.Open();
conn.Close();
}
}
Enjoy!
P.S.: Npgsql2 code is found in Npgsql2 cvs module. See here for more info about how to get it.
Warning: This is a very early code, so bugs still exist and there are things missing. Basic functionality should work ok.
<?xml version="1.0" encoding="iso-8859-1" ?>
<configuration>
<system.data>
<DbProviderFactories>
<add name="Npgsql Data Provider" invariant="Npgsql" support="FF" description=".Net Framework Data Provider for Postgresql Server" type="Npgsql.NpgsqlFactory, Npgsql, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" />
</DbProviderFactories>
</system.data>
</configuration>
Thomas said that "the tags are case sensitive and the
Thank you Thomas for your feedback which, for sure will help others to get their configuration up and running. I will check with Mono guys to see why my original configuration worked.
Hi all!
Today I committed an initial support for provider factory to Npgsql2.
This will allow ado.net 2.0 users to work with Npgsql using ado.net generic coding.
In order to use it, you have to add the following xml config in your machine.config or yourapp.exe.config file:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<configuration>
<appsettings>
<system.data>
<dbproviderfactories>
<add name="Npgsql Data Provider" invariant="Npgsql" support="FF" description=".Net Framework Data Provider for Postgresql Server" type="Npgsql.NpgsqlFactory, Npgsql, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7">
</add>
</dbproviderfactories>
</system.data>
</appsettings>
</configuration>
P.S.: Sorry for indentation lacking. I don't know how to add it on blogger :(
Note that this is the full contents of a yourapp.exe.config file. If you are changing the machine.config file, just add the "add name=..." section.
The key elements here are the invariant name which will be used in your application when returning the provider factory. In this case it is defined as "Npgsql". But you can specify whatever you want.
That's it! If everything is ok, you will be able to write some code like that, to connect to postgresql:
using System;
using System.Data;
using System.Data.Common;
public class c
{
public static void Main(String[] args)
{
DbProviderFactory factory = DbProviderFactories.GetFactory("Npgsql");
DbConnection conn = factory.CreateConnection();
conn.ConnectionString = "Server=127.0.0.1;User id=npgsql_tests;password=npgsql_tests;";
conn.Open();
conn.Close();
}
}
Enjoy!
P.S.: Npgsql2 code is found in Npgsql2 cvs module. See here for more info about how to get it.
Warning: This is a very early code, so bugs still exist and there are things missing. Basic functionality should work ok.
Comments
Great work, cheers!
Dan
many thanks for your good work. I downloaded the CVS version, compiled it, made the entries in machine.config and it seems to work quite well.
Do you have any intention to build a configuration utility (DbProviderConfigurationHandler?) so that you can connect to it using the Server Explorer in Visual Studio?
Kind regards
Trevor D'Arcy-Evans
Mas acabei me deparando com um problema. Tenho um banco postgres em UTF8, e ao tentar salvar uma string com acentos ele diz que não aceita a sequencia de bytes:
ERROR: 22021: invalid byte sequence for encoding "UTF8": 0xe97374
A sequencia que mandei foi "Téste Ç" (sem as aspas)
Chequei o Request.ContentEncoding do aspnet e ele está em UTF8.
Pode me dar alguma informação sobre este problema?
Aguardo seu contato.
junalmeida@msn.com; junalmeida@gmail.com
Just create your database with the default encoding (SQL_ASCII) and you should be able to insert and retrieve accented characters fine :)
Don´t know the logic behind this (hints someone?), but worked like a charm for me.
白蟻
除白蟻
白蟻防治
跳蚤
除跳蚤
跳蚤防治
蛀蟲
除蛀蟲
蛀蟲防治
白蟻
除白蟻
白蟻防治
跳蚤
除跳蚤
跳蚤防治
蛀蟲
除蛀蟲
蛀蟲防治
除蟲
除蟲