views:

981

answers:

1

Hi,

I have PostgresQL database, and I develop interface application using C# and Npgsql to connect to the database, how can I assign the Npgsql connection to TableAdapter?

Thanks,

+1  A: 

I'm in the exact same boat with PostgreSQL.

I don't believe that's possible. Npgsql has its own data adapter (see http://npgsql.projects.postgresql.org/docs/manual/UserManual.html and search for text "adapter"). The downside to this is that you can't use the Visual Studio Designer.

So instead, I'm using .NET's ODBC DataSource. For this to work, you will need to install the postgresql odbc driver, which is available here: http://www.postgresql.org/ftp/odbc/versions/msi/. After installing, you can go to Control Panel -> Administrative Tools -> Data Soruces (ODBC) to add a DSN (Data Source Name). Finally, in Visual Studio go to the Server Explorer, right click "Data Connections" and select "Add Connection...", and change the data source of Microsoft ODBC Data Source. Here you can select the DSN you provided earlier, and viola! You're in business.

(Note that for some crazy reason bools come in as strings. You can change this in the ODBC Data Source Administrator by clicking "Configure" on your PostgreSQL datasource, going to Datasource options, and unchecking "Bools as Char".)

Kyle Ryan