There is already an open DataReader associated with this Command which must be closed first.
Posted on 2007-10-01
I'm returning to coding after 10 years away. I used asp way back in the day, but things are a bit different with asp.net. 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.