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

  • Home
  • SEARCH
  • 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 6646109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:22:34+00:00 2026-05-26T00:22:34+00:00

I am using IBM OLE DB Provider for connecting to DB2. I can open

  • 0

I am using IBM OLE DB Provider for connecting to DB2.

I can open more than one DataReader on a single OleDbConnection.Does this provider implicitly opens an additional connection for each DataReader.

If so,will this connections closed automatically or stay open until the connection get time-out.

  OleDbConnection connection = new (connectionString);
  OleDbDataReader reader = null;
  try
    {
      connection.Open();
      reader = OleDbHelpher.ExecuteNonQuery(connection, CommandType.Text,query1);
      while (reader.Read())
      {
        Console.WriteLine(reader[0].ToString());
      }
      reader.Close();

      reader = OleDbHelpher.ExecuteNonQuery(connection, CommandType.Text,query2);
      while (reader.Read())
      {
        Console.WriteLine(reader[0].ToString());
      }
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex.Message);
    }
    finally
    {
     connecton.Close();
    }  
  • 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-26T00:22:34+00:00Added an answer on May 26, 2026 at 12:22 am

    If you have a try/finally block the way you have it now, the connection will always be closed.

    No, you can’t open more than one DataReader on a single connection. You will get an exception if you attempt something like this.

    From MSDN:

    Note that while a DataReader is open, the Connection is in use
    exclusively by that DataReader. You cannot execute any commands for the Connection,
    including creating another DataReader, until the original DataReader
    is closed.

    Instead, open 2 connections (don’t worry about the penalty since most likely your connections are pooled anyway) and make sure that you close the connection in a finally block or instead use a using statement.

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

Sidebar

Related Questions

We have an application using the IBM Informix driver. Whenever we try to open
We're using DB2 9.1 on Linux and SQL Server 2005, and the IBM db2
I am using IBM DB2 V 9.1.0.356. I am using DB2 JDBC driver version
Hi we are using IBM Commerce Sever Moving from one view to another using
I am using IBM DB2 with Toad. I have a stored procedure that I
How do I execute an SQL string statement in DB2? I'm using IBM Data
I am using AS/400 with Reflections for IBM. Here is my question: How can
I'm using IBM DB2 9.7.2 on Debian GNU/Linux. I need a conditional DROP INDEX,
I am using IBM DB2. I have a query which gives the output as:
Using IBM Rational ClearCase: - I have only access to Snapshot Views so NO

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.