Dapper: Exception after first query in Postgresql

Created on 20 May 2016  Â·  5Comments  Â·  Source: StackExchange/Dapper

Im using postgresql 9.4.1.The basic code below. Quering the first time is OK, but crashed when running twice. And Strangely,if I execute "INSERT" twice instead of "SELECT" ,The data has been inserted into database both,then crashed..

using (var conn = new NpgsqlConnection("Server=xxxxxxxxxxxx"))
{
    conn.Open();
    var foo = conn.Query("select * from test where id>=@id", new { id = 1 });
    conn.Close();
    conn.Dispose();
}

Message:"Exception while reading from stream"
And InnerException shows the connection looks like Server no response,

Most helpful comment

I have found the answer,
Im sorry ,It is Npgsql's problem with the latest stable version of 3.1.1 on
http://www.nuget.org/packages/Npgsql/3.1.1
when I change to 3.1.0-alpha6 or 3.0.7, it back to normal.....

All 5 comments

What happens if you remove conn.Close() and conn.Dispose() (your 'using'
statement should account for both of those calls)?

On Fri, May 20, 2016 at 6:33 AM, jimifish [email protected] wrote:

Im using postgresql 9.4.1.The basic code below. Quering the first time is
OK, but crashed when running twice. And Strangely,if I execute "INSERT"
twice instead of "SELECT" ,The data has been inserted into database
both,then crashed..

using (var conn = new NpgsqlConnection("Server=xxxxxxxxxxxx"))
{
conn.Open();
var foo = conn.Query("select * from test where id>=@id", new { id = 1 });
conn.Close();
conn.Dispose();
}

Message:"Exception while reading from stream"
And InnerException shows the connection looks like Server no response,

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
https://github.com/StackExchange/dapper-dot-net/issues/519

@BlackjacketMack I have tried all the ways but nothing changed

I don't know that helps but should not look the connection string like this

new NpgsqlConnection("Host=xxxxxxxxxxxx")

instead of

new NpgsqlConnection("Server=xxxxxxxxxxxx")

@stevo-knievo both "host" and "server" can be used,but still getting exception.
I hope you can try it ! please do me a favor

I have found the answer,
Im sorry ,It is Npgsql's problem with the latest stable version of 3.1.1 on
http://www.nuget.org/packages/Npgsql/3.1.1
when I change to 3.1.0-alpha6 or 3.0.7, it back to normal.....

Was this page helpful?
0 / 5 - 0 ratings

Related issues

huobazi picture huobazi  Â·  4Comments

CrescentFresh picture CrescentFresh  Â·  4Comments

wrjcs picture wrjcs  Â·  5Comments

PeterWone picture PeterWone  Â·  5Comments

rafakwolf picture rafakwolf  Â·  5Comments