Client 1—Connecting to the Server

Connecting a VB.NET application to a PostgreSQL database is easy. Simply add an NpgsqlConnection object to your application and set the ConnectionString property. You can open the connection programmatically, or let another Npgsql object manage the connection as needed.

To create an NpgsqlConnection object, open the Data tab (in the Toolbox) and double-click the NpgsqlConnection tool—Visual Studio adds an NpgsqlConnection object to the form that you're editing. If you see a message that states “The .NET assembly 'Npgsql' could not be found.”, you forgot to add an Npgsql reference to your project. See the previous section (“Creating an Npgsql-enabled VB.NET Project”) to learn how to fix the problem.

To define ...

Get PostgreSQL, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.