There is already an open DataReader associated with this Command which must be closed first.

Posted on 2007-10-01
Last Modified: 2013-11-07
I'm returning to coding after 10 years away.  I used asp way back in the day, but things are a bit different with  Still, it's coming along a bit.  i'm try to build some pages to test out operability before I implement them as functional pages on our site.  And so far, for every problem I've come up against, I've found a solution pretty easily.  But I cannot solve this "there is already an open datareader" one.  I've found quite a bit about it, but it all seems to be so much more complex that what I'm doing here...and if I'm getting this error on a simple dropdown box (which will eventually provide consecutive dropdowns based on the option chosen here), I can imagine how frustrating it would be with a huge app with lots of data connections, etc.

Anyway, here's my simple, but not working, code.


<%@ Page aspcompat=true language="vb" debug="true"%>

<% @Import Namespace="System.Data" %>
<% @Import Namespace="System.Data.OleDb" %>

  Const sConnStr as String="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Northwind\PMTemp.mdb" & ";"
  Dim objConn as New OleDbConnection(sConnStr)

  Const strSQL as String="SELECT VendorName, ID FROM Vendor"
  Dim objCmd as New OleDbCommand(strSQL, objConn)
  Dim objDR as OleDbDataReader

  <asp:listbox id="lstVendors" runat="server" Rows="1"
               DataTextField="VendorName" DataValueField="ID" />


any help would be appreciated.
Question by:mychiefs58
    1 Comment
    LVL 26

    Accepted Solution

    >> objDR=objCmd.ExecuteReader()

    comment the first line

    or change the second line to

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project ( automates most of the tasks discussed in this article. You can even fin…
    Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
    The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
    The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now