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 7091237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:09:35+00:00 2026-05-28T08:09:35+00:00

here is code String[] month=new String[12]{January,February,March,April,May,June,July,August,September,Octomber,November,December}; int day = DateTime.Now.Day; int mon= DateTime.Now.Month; mon

  • 0

here is code

    String[] month=new String[12]{"January","February","March","April","May","June","July","August","September","Octomber","November","December"};
    int day = DateTime.Now.Day;
    int mon= DateTime.Now.Month;
    mon = mon - 1;      //because month array is with 0
    Label1.Text = day.ToString();
    if (day==21)
    {
        int j = 1;
        SqlCommand cmd1 = new SqlCommand();
        cmd1.Connection = MyConn;
        cmd1.CommandText = "SELECT No_of_times,Dustbin_no from mounthly_data";
        SqlDataReader MyReader = cmd1.ExecuteReader();
        while (MyReader.Read())
        {
            String a = MyReader["No_of_times"].ToString();
            String b = MyReader["Dustbin_no"].ToString();

            SqlCommand cmd = new SqlCommand();
            cmd.Connection = MyConn;
            cmd.CommandText = "update Yearly_data set [" + month[mon] + "]='"+a+"' where Dustbin_no='"+b+"'";   //just see ["+month[mon+"] it's imp
            i = cmd.ExecuteNonQuery();    
        }
        MyReader.Close();
    }

i got error as

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

  • 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-05-28T08:09:35+00:00Added an answer on May 28, 2026 at 8:09 am

    I think you should give us the rest of the code above this code block because I’m not sure how a ExecuteNonQuery is using up a datareader. But from what I can gather, what you probably want is to open two separate connections. Only one datareader can be open per connection at a time. Either you use two separate connections or you could maybe use a datatable/dataset for the result of both your queries.

    EDIT: From the rest of your code, yes, using two connections would be the simplest answer. When a reader is open, the connection associated with it is dedicated to the command that is used, thus no other command can use that connection.

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

Sidebar

Related Questions

Here is my code: new Loading.LoadTast(ctx) { @Override protected String doInBackground(Integer... params) { Looper.prepare();
Here's the code: string name = myName; int id = (int)_myDB.ThingTable.Where(thing => thing.ThingName ==
Here is the code: string str; cin>>str; cout<<first input:<<str<<endl; getline(cin, str); cout<<line input:<<str<<endl; The
In the following code: public class A { public A():this(null){} public A(string b){/*code here*/}
I'm writing a lexer in haskell. Here's the code: lexer :: String -> [Token]
here is code for regular expression matching #include<iostream> #include<stdio.h> #include<string.h> using namespace std; int
here is the code public static final String DATE_TIME_FORMAT = yyyy-MM-dd kk:mm:ss; public static
Here is my code : public static void main(String[] args) { // System.setProperty( //
Here's the code snippet: public static void main (String[]arg) { char ca = 'a'
Here is my code: class Soldier { public: Soldier(const string &name, const Gun &gun);

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.