LoginSignup
0
0

More than 3 years have passed since last update.

c# posgre 接続 select

Last updated at Posted at 2020-06-01


using System;
using Npgsql;

namespace db01
{
    class Program
    {
        static void Main(string[] args){
            //接続文字列
            NpgsqlConnection conn = new NpgsqlConnection("Server=localhost;Port=5432;User ID=postgres;Database=postgres;Password=Chatdb01;Enlist=true");
            //PostgreSQLへ接続
            conn.Open();


            NpgsqlCommand cmd = new NpgsqlCommand("select version()", conn);
            var serverversion = (String)cmd.ExecuteScalar();

            Console.WriteLine("PostgreSQL server version: {0}", serverversion);
            conn.Close();
        }
    }
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0