Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6999013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:29:09+00:00 2026-05-27T20:29:09+00:00

This is an example given in the manual. When I try the same, i

  • 0

This is an example given in the manual. When I try the same, i get umpteen exceptions. What is the mistake in this.

using(NpgsqlConnection conn = new NpgsqlConnection("connstring"))
{
    conn.Open();
    using(NpgsqlCommand command = new NpgsqlCommand("select command", conn))
    {
        command.Parameters.Add(new NpgsqlParameter("column1", NpgsqlDbType.Integer);
        command.Parameters[0].Value = 4;
        using(NpgsqlDataReader dr = command.ExecuteReader())
        {
            dr.Read();
            Console.Write("{0} \t", dr[0]);
        }
    }
}

Exception :

System exception System.IO.IOException: I/O error occurred.
at Npgsql.NpgsqlState.<ProcessBackendResponses_Ver_3>d__a.MoveNext()
at Npgsql.NpgsqlState.IterateThroughAllResponses(IEnumerable`1 ienum)
at Npgsql.NpgsqlState.Query(NpgsqlConnector context, NpgsqlCommand command)
at Npgsql.NpgsqlConnector.Query(NpgsqlCommand queryCommand)
at Npgsql.NpgsqlConnector.ReleaseRegisteredListen()
at Npgsql.NpgsqlConnector.ReleaseResources()
at Npgsql.NpgsqlConnectorPool.UngetPooledConnector(NpgsqlConnection Connection, NpgsqlConnector Connector)
at Npgsql.NpgsqlConnectorPool.ReleasePooledConnectorInternal(NpgsqlConnection Connection, NpgsqlConnector Connector)
at Npgsql.NpgsqlConnectorPool.ReleasePooledConnector(NpgsqlConnection Connection, NpgsqlConnector Connector)
at Npgsql.NpgsqlConnectorPool.ReleaseConnector(NpgsqlConnection Connection, NpgsqlConnector Connector)
at Npgsql.NpgsqlConnection.Close()
at Npgsql.NpgsqlConnection.Dispose(Boolean disposing)
at System.ComponentModel.Component.Dispose()

Now this works correctly. What’s the difference :

using(NpgsqlConnection conn = new NpgsqlConnection("connstring"))
{
    conn.Open();
    using(NpgsqlCommand command = new NpgsqlCommand("select command", conn))
    {
        command.Parameters.Add(new NpgsqlParameter("column1", NpgsqlDbType.Integer);
        command.Parameters[0].Value = 4;
        NpgsqlDataReader dr = command.ExecuteReader();            
        dr.Read();
        Console.Write("{0} \t", dr[0]);
    }
}

why datareader cannot be used with Idisposable ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:29:10+00:00Added an answer on May 27, 2026 at 8:29 pm

    Npgsql doesn’t handle connection interuptions if you are using datareader with the Idisposable. If the server is terminating the connection before it is communicating to the application and when the connection returns to the connection pool , it goes to the server to check the connection and by this time, the datareader doesn’t get disposed properly. In a multi-threaded environment, this will come up in unfortunate circumstances. If the server is disconnecting itself from an connection, it should not terminate so immediately that the Npgsql is not able to communicate back to it. Increase the server’s disconnecting time to be higher. Mine is a case of disconnecting the server abruptly forcibly.

    Solution : Npgsql should handle the exception internally which is not yet present.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the email address: Jim <jim@example.com> If I try to pass this to MailAddress
Given this example: <img class=a /> <img /> <img class=a /> <img class=a id=active
Given this example XML file: <doc> <tag> Hello ! </tag> <tag> My name is
Given this example, how would I return the result of the equation rather than
I'm trying to solve this problem : http://uva.onlinejudge.org/external/7/732.html . For the given example, they
Given the example below, can someone please show me how this could be called?
This is just an example, but given the following model: class Foo(models.model): bar =
This is easier to explain with an example. Given these two classes: public class
In PHP manual given example is echo substr_compare(abcde, bcg, 1, 2); // 0 I
The grails manual shows the following example: <g:set var=now value=${new Date()} scope=request /> and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.