.Net 4.5、Npgsql 3.1.6 NuGet パッケージで Postgres Plus 9.5 を試しています。このエラーについてここに書かれていることを読みましたが、なぜこのエラーが発生するのかわかりません。すべてが処分されます。ここにコードがあります:
public override DataTable getActListData(int FunkNr)
{
using (var cmd = new NpgsqlCommand())
{
cmd.CommandText = npgsqlCommand3.CommandText;
cmd.Connection = this.npgsqlConnection;
cmd.Parameters.Add(new Npgsql.NpgsqlParameter("ANWENDUNG", NpgsqlTypes.NpgsqlDbType.Numeric));
cmd.Parameters.Add(new Npgsql.NpgsqlParameter("XFUNKNR", NpgsqlTypes.NpgsqlDbType.Numeric));
using (var da = new NpgsqlDataAdapter(npgsqlCommand3))
{
var tab = new DataTable();
da.SelectCommand.Parameters["ANWENDUNG"].Value = getAnwendung();
da.SelectCommand.Parameters["XFUNKNR"].Value = FunkNr;
da.Fill(tab); // Here is the error on the 5th call
return tab;
}
}
}
この問題は Npgsql によるものですか、それとも Postgres によるものですか?
その他の質問:
私はここで、遅延読み込みが不可能であることを読みましたが、NpgsqlまたはPostgresが原因であるとは理解していませんでしたか?
Postgres で複数のカーソルを開き、同じ接続でオンデマンドで読み取ることは可能ですか?
編集:コードを変更しました:
using (var npgsqlConnection = new NpgsqlConnection())
{
ConnectionString = string.Format(DataClientFactory.DataBaseConnectString, DB, User, PW);
npgsqlConnection.ConnectionString = ConnectionString;
npgsqlConnection.Open();
....
the code above here
....
}
同じ呼び出しで同じエラー。エラー:
System.InvalidOperationException occurred
HResult=-2146233079
Message=An operation is already in progress.
Source=Npgsql
StackTrace:
bei Npgsql.NpgsqlConnector.StartUserAction(ConnectorState newState)
InnerException: