Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / database / PostgreSQL

A PostgreSQL Notification Example

5.00/5 (15 votes)
15 Oct 2020CPOL1 min read 43.3K   2.9K  
PostgreSQL notifications Windows Forms application
In this tip, you will see a fully fledged PostgreSQL notifications WinForms application created with VS 2013.

Introduction

This is a fully fledged PostgreSQL notifications Windows Forms application created with Visual Studio 2013.

There is also an updated version for VS2019 which uses Npgsql 4.1.5.

When searching the internet, I only found scraps of information on how to do notification events in PostgreSQL, but not a complete working example.

Image 1

Using the Code

So here it is, the only thing that needs to be present is a database, the table and triggers will be created by the application.

I tested the old version with PostgreSQL 9.5 and the NpgSql 2.1.3 driver.

The updated version was tested with PostgreSQL 10.14 and NpgSql 4.1.5.

After pressing the <Start> button, listening starts with the PostgreSQL "listen mynotification" command.
Notification events can be triggered from the application using the <Trigger> and <Insert row> buttons, and also by directly editing the database.

Image 2

Points of Interest

More information can be found from the links below:

There is also a portable PostgreSQL version, I don't like the newest versions as they tend to be bigger and don't have PgAdminIII included with them, so my favourite remains version 9.4.5 which is only a 10 MB download.

You can download it from the link provided on top, or from:

History

  • V 1.0 Old version
  • V 2.0 New version for NpgSql 4.1.5

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)