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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:23:12+00:00 2026-06-07T14:23:12+00:00

this is the url i refer to: http://support.microsoft.com/kb/317559 i study their method and had

  • 0

this is the url i refer to: http://support.microsoft.com/kb/317559

i study their method and had applied them, everything is fine until i include 2_2, error msg: No current query in data reader.

I already close my drSelect1_1 under 2_1 if statement. I need to close it or else i cant create a new one. so problem is, how to open the drSelect1_1 again so that i can use for my 2_2? i tried to create drSelect1_1a instead of use back drSelect1_1, got error with: Invalid attempt to access a field before calling Read() .
any advice? code as below:

cmdSelect.CommandText = "SELECT * FROM member WHERE username = @username";

connSelect.Open();

MySqlDataReader drSelect1_1 = cmdSelect.ExecuteReader();

if (drSelect1_1.Read())
{
     //1_1
     this.lbl1_1.Text = drSelect1_1["username"].ToString();

     //2_1
     if (drSelect1_1["direct1"].ToString() != "")
     {
        //this.ib2_1.Visible = true;
        this.lbl2_1.Text = drSelect1_1["direct1"].ToString();
        drSelect1_1.Close();

        cmdSelect.CommandText = "SELECT * FROM member WHERE username = '" + this.lbl2_1.Text + "'";
        MySqlDataReader drSelect2_1 = cmdSelect.ExecuteReader();

        if (drSelect2_1.Read())
        {                  
             drSelect2_1.Close();
        }
    }

    //2_2            
    if (drSelect1_1["direct2"].ToString() != "")
    {

    }
}
connSelect.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-06-07T14:23:13+00:00Added an answer on June 7, 2026 at 2:23 pm

    EDIT #2

    Alright, well if that’s the case. Assign the values to variables at the beginning of the block, before closing the reader. It will save you from so much trouble. 🙂

    if (drSelect1_1.Read())
    {
         string username = drSelect1_1["username"].ToString();
         string direct1 = drSelect1_1["direct1"].ToString();
         string direct2 = drSelect1_1["direct2"].ToString();
    
         drSelect1_1.Close();
    
         //1_1
         this.lbl1_1.Text = username;
    
         //2_1
         if (direct1 != "")
         {
            //this.ib2_1.Visible = true;
            this.lbl2_1.Text = direct1;
    
            cmdSelect.CommandText = "SELECT * FROM member WHERE username = '" + this.lbl2_1.Text + "'";
            MySqlDataReader drSelect2_1 = cmdSelect.ExecuteReader();
    
            if (drSelect2_1.Read())
            {                  
                 drSelect2_1.Close();
            }
        }
    
        //2_2            
        if (direct2 != "")
        {
    
        }
    }
    

    You have closed your data reader drSelect1_1.Close(); and tried accessing it again at

    if (drSelect1_1["direct2"].ToString() != "")
    

    Remove this line

    drSelect1_1.Close();
    

    Or just move before it before the } in your Read() block.

    EDIT:

    Just create another instance of MySqlCommand, do it like this:

    MySqlCommand cmdSelect2 = new MySqlCommand("SELECT * FROM member WHERE username = '" + this.lbl2_1.Text + "'", connSelect);
    MySqlDataReader drSelect2_1 = cmdSelect2.ExecuteReader();
    

    So you can safely remove the above mentioned line.

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

Sidebar

Related Questions

I am using this URL http://search.twitter.com/search.json to grab tweets with the hash tag #SameHashTag
I want this url http://www.youtube.com/watch?v=dgNgODPIO0w&feature=rec-HM-fresh+div to be transformed to: http://www.youtube.com/v/dgNgODPIO0w with php.
Please refer to this page for reference: http://loadedgranola.valitics.com/_product_83484/blackberry_lime I have a jQuery script that
I have this URL example.com/photo?people I want to rewrite this URL in the form
I'm having this url parameter: http://127.0.0.1:8000/information/vimeo/?oauth_token=xxxxxxxxxxxxxxxxxxxxxxxx&oauth_verifier=xxxxxxxxxxxxxxxxxxxxxx How can I get the value of oauth_verifier
do you test this url in your application that writted with cakephp ? www.yourCakephpApp.com/test
First look at this url: https://stackoverflow.com/questions/tagged/xoxoxo/ This directory does not exists but somehow stackoverflow
I want to scrape this URL : https://www.xstreetsl.com/modules.php?searchSubmitImage_x=0&searchSubmitImage_y=0&SearchLocale=0&name=Marketplace&SearchKeyword=business&searchSubmitImage.x=0&searchSubmitImage.y=0&SearchLocale=0&SearchPriceMin=&SearchPriceMax=&SearchRatingMin=&SearchRatingMax=&sort=&dir=asc Go into each of the links
Using this tutorial: http://dotnetslackers.com/articles/ajax/Using-jQuery-with-ASP-NET.aspx The web service is invoked such as Service1.asmx/HelloToYou The default
Please refer the url http://jsfiddle.net/fnvXT/ Here while selecting the check box the corresponding row

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.