Click here to Skip to main content
14,173,097 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi everybody. I am using PgAdmin 4 as Database in order to put some query results in a chart. I can barely find good examples of codes in order to do it. Could anyone possibly help me with it or introduce me a good source?I am new to programming so my codes may not look really nice or professional. PLEASE HELPPPP

What I have tried:

using System;
using Npgsql;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DBConnectExperiment
    class Program
        static void Main(string[] args)

            string query = "select count(fietsdiefstal.buurt), from fietsdiefstal inner join climat on fietsdiefstal.year = climat.year group by (fietsdiefstal.buurt), ";

            string ip = "";
            string port = "5432";
            string database = "project3";
            string username = "project3";
            string password = "project3";
            string deliminator = ";";

            string connectionParameter = String.Format("Server=" + ip + deliminator + "Port=" + port + deliminator + "User Id=" + username + deliminator + "Password=" + password + deliminator + "Database=" + database);
                NpgsqlConnection conn = new NpgsqlConnection(connectionParameter);
                Console.WriteLine("connection has been made");
                Console.WriteLine("database is openned ...");

                NpgsqlCommand queryCommand = new NpgsqlCommand(query, conn);
                NpgsqlDataReader dataReader = queryCommand.ExecuteReader();

                while (dataReader.Read())
                    //Chart vullen
                    Console.WriteLine("{0} \t {1} \n", dataReader[0], dataReader[1]);

                Console.Write("I executed this query" + query);
            catch (Exception e)

Updated 18-Mar-18 9:47am
Kornfeld Eliyahu Peter 18-Mar-18 10:10am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Take a look at this CodeProject library: A flexible charting library for .NET[^]
Sadly, according to some comments on his article, the author seems to have passed away some years ago ...

If you are looking for interactive charts then this looks promising: GitHub - Live-Charts/Live-Charts: Simple, flexible, interactive & powerful charts, maps and gauges for .Net[^]

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Cookies | Terms of Service
Web02 | 2.8.190524.3 | Last Updated 18 Mar 2018
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100