2
下午好,Npgql get_HasRows()拋出ArgumentOutOfRangeException
我真的正在與AspNetCore和MVC開發和使用PostgreSQL(Npgsql的)作爲我的數據庫。
當他們有一些結果我的查詢工作正常。
當查詢返回空結果時,我得到一個ArgumentOutOfRangeException錯誤。
System.ArgumentOutOfRangeException: Argument is out of range.
Parameter name: Got unexpected message type: ReadyForQuery
in Npgsql.NpgsqlDataReader.get_HasRows()
in QueryPostgreSQL.IsEmpty()
in sistema_cotacao.Controllers.LoginController.<Index>d__2.MoveNext() in \Visual Studio 2015\Projects\sistema-cotacao\src\sistema-cotacao\Controllers\LoginController.cs:line 66
這是發生錯誤的代碼(在query.IsEmpty()
):
if ((query.IsEmpty()) || (usuario.enti_email != usu.enti_email))
{
...
query.Close();
return View();
}
else
{
....
query.close();
return Redirect("/Login");
}
而且我IsEmpty()
功能是:
private NpgsqlDataReader queryPostgreSQL;
...
public Boolean IsEmpty()
{
Boolean bResult = true;
bResult = !queryPostgreSQL.HasRows;
return bResult;
}
我couldn`t尋找到我的問題是。
我付出了,但我不確定。感謝您的回答! –