Jump to content

Error - There is already an open DataReader associated with Command which must be closed first


Recommended Posts

When I click on listBox1, I have 2 error messages

ERROR: There is already an open DataReader associated with Command which must be closed first
        this.unitTableAdapter1.FillBy(this.dataSet_Property_Name_And_Unit_List.Unit);

ERROR: System.ArgumentNullException: 'Value cannot be null. Parameter name: key'
       catch (System.Exception ex)

///////////////////////////////////////

DataSet_Property_Name_And_Unit_List.xsd --> Right Click - -> Open --> UnitTableAdapter --> Right Click --> Configure
SELECT Property_Name, Unit_Number FROM Unit

///////////////////////////////////////

DataSet_Unit_Detail.xsd --> Right Click - -> Open --> UnitTableAdapter --> Right Click --> Configure
SELECT Unit_Number, Property_Name, Rental_Cost, Security_Deposit, Bedroom, Bathroom, Square_Feet, Status
FROM Unit WHERE (Property_Name = '@Property_Name')

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Retrieve_Data_From_Access_With_Navigation_Button
{
    public partial class Form3 : Form
    {
        public Form3()
        {
           InitializeComponent();
        }

        private void unitBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
           this.Validate();
           this.unitBindingSource.EndEdit();
           this.tableAdapterManager.UpdateAll(this.dataSet_Unit_Detail);
        }

        private void Form3_Load(object sender, EventArgs e)
        {
ERROR: System.ArgumentNullException: 'Value cannot be null. Parameter name: key'
           this.unitTableAdapter1.Fill(this.dataSet_Property_Name_And_Unit_List.Unit);
           this.unitTableAdapter.Fill(this.dataSet_Unit_Detail.Unit);
        }

        private void fillByToolStripButton_Click(object sender, EventArgs e)
        {
            try
            {
                this.unitTableAdapter1.FillBy(this.dataSet_Property_Name_And_Unit_List.Unit);
            }
            catch (System.Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }
        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
              ERROR BELOW: There is already an open DataReader associated with Command 
              which must be closed first
              this.unitTableAdapter1.FillBy(this.dataSet_Property_Name_And_Unit_List.Unit);
            }

            ERROR BELOW: System.ArgumentNullException: 'Value cannot be null. Parameter name: key'
            catch (System.Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }
        }
    }
}
 
 
 
 
Last edited: Thursday at 5:43 PM
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...