Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 3 of 3
  1. #1
    Senior Member blackbird's Avatar
    Join Date
    Jan 2004
    Location
    San Francisco, CA
    Posts
    100
    Member #
    4730
    My function looks like:

    Code:
    private void cboTableNumber_SelectedIndexChanged(object sender, System.EventArgs e)
    	   {
    		this.oleSelectTableInfoCommand.Parameters[ "TableNumber" ].Value = this.cboTableNumber.SelectedItem;
    		OleDbDataReader myReader = this.oleSelectTableInfoCommand.ExecuteReader();
    		while (myReader.Read())
    		{
    			this.lblSubtotalResult.Text=Convert.ToString(myReader["Subtotal"]);
    			this.lblName.Text=Convert.ToString(myReader["WaiterName"]);
    		}
    		myReader.Close();
    	   }
    and it compiles fine, but when I select a TableNumber from the comboBox, I get an error of "ExecuteReader requires an open and available connection. This connection's current state is Closed." Anyone have any idea why?? This exact code works in the rest of my functions and I've checked to make sure they all open and close their readers.

    *baffled*
    http://www.pearlsgirl.com

  2.  

  3. #2
    Senior Member blackbird's Avatar
    Join Date
    Jan 2004
    Location
    San Francisco, CA
    Posts
    100
    Member #
    4730
    Nevermind. It dawned on me that this function wasn't being called by another one that opened and closed the database connection also.
    http://www.pearlsgirl.com

  4. #3
    Junior Member
    Join Date
    Jan 2005
    Posts
    1
    Member #
    8645
    I also had similiar problem. Easy fix to this problem is to close the connection at the end of function and open it again when you make a function call

    Rishi


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 12:00 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com