お世話になります。
この旅、C#でPosgresqlに接続する必要が出て参りましたため、
お試しでC#のコンソールアプリケーションからPostgresqlへの接続を試みておりますが、
接続出来ない旨のエラーが出続け、接続出来ておりません。
何かヒントでも構いませんのでご教示頂けないでしょうか。
なおDBのconfを疑い下記を実施しましたが、問題なく接続出来ました。
・psqlを用いての接続
・JavaでConnectionクラスを用いての接続
OS : Windows 7 Pro 開発環境:Visual Studio Express 2015 Postgresql : 9.1 Npgsqlのバージョン:3.0.5 追加した参照:Mono.Security.dll、NpgSql.dll
C#
1using Npgsql; 2using System; 3 4namespace ConsoleApplication2 5{ 6 class Program 7 { 8 static void Main(string[] args) 9 { 10 NpgsqlConnection conn = new NpgsqlConnection(); 11 conn.ConnectionString = @"Server=localhost;Port=5432;Database=testdb;User Id=testdb;Password=testdb;"; 12 NpgsqlCommand command = new NpgsqlCommand(@"select * from syorui", conn); 13 NpgsqlDataReader dataReader = command.ExecuteReader(); 14 while (dataReader.Read()) 15 { 16 Console.WriteLine("value : {0}", dataReader["hoge"]); 17 } 18 } 19 } 20}
型 'System.InvalidOperationException' のハンドルされていない例外が Npgsql.dll で発生しました 追加情報:Connection is not open
お手数おかけ致しますが、よろしくお願い致します。

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。