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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:01:30+00:00 2026-05-13T13:01:30+00:00

I am developing a WinForm Application in C Sharp on the .net framework. The

  • 0

I am developing a WinForm Application in C Sharp on the .net framework.
The database string I am using as of now is

<add key="Conn" value="Data Source=MNTCON016; Database=Overtime_Calculator;Trusted_Connection=True;MultipleActiveResultSets=true" />

As I am using Microsoft SQL Server 2005 for development, I can use 2 data readers simultaneously using the MultipleActiveResultSets property to true as mentioned above.

The Method used to invoke the 2 data readers is as follows:

    public static void SignUpControllerDay(DateTime Date, System.Windows.Forms.DataGridView PassedGrid)
    {
        string sql_SignUp = String.Format(@"SELECT Emp_ID as Emp_ID, Name as Name, Sum(Sum) as Sum FROM
                                            (SELECT DISTINCT o.Date, e.Emp_ID as Emp_ID,
                                            e.First_Name+ ' ' +e.Last_Name as Name,
                                            o.Quantity as Sum
                                            FROM Employee e,OT_Hours o,Position p,Signup_Sheet s
                                            WHERE e.Emp_ID=o.Emp_ID
                                            and e.Emp_ID = s.Employee_ID
                                            and s.Day_Shift = 1
                                            and e.Position_ID = p.Position_ID
                                            and p.Position_Name = 'Controller'
                                            and o.Quantity NOT IN(0.3)
                                            and s.Date = '{0}'
                                            and o.Date <= CONVERT(VARCHAR,'{0}',101) AND o.Date > CONVERT(VARCHAR,DATEADD(YYYY,-1,'{0}'),101) )
                                            as OVERTIME
                                            GROUP BY Emp_ID,Name
                                            ORDER BY Sum", Date);

        SqlConnection sqlConn = null;
        SqlCommand cmd_SignUp;
        SqlDataReader dr_SignUp;
        try
        {
            sqlConn = new SqlConnection(databaseConnectionString);
            sqlConn.Open();
            cmd_SignUp = new SqlCommand(sql_SignUp, sqlConn);
            dr_SignUp = cmd_SignUp.ExecuteReader();

            while (dr_SignUp.Read())
            {
                ArrayList arrPhone = new ArrayList();
                string sql_Phone = String.Format("SELECT Phone_Number FROM Contact_Details WHERE Emp_ID = {0}", dr_SignUp["Emp_ID"]);
                SqlCommand cmd_Phone = new SqlCommand(sql_Phone, sqlConn);
                SqlDataReader dr_Phone = cmd_Phone.ExecuteReader();
                while (dr_Phone.Read())
                {
                    arrPhone.Add(dr_Phone["Phone_Number"].ToString());
                }
                //--Retrieving Sectors
                ArrayList arrSector = new ArrayList();
                string sql_Sector = String.Format(@"SELECT e1.EMP_ID,
                                                ( SELECT cast(Sector_ID as varchar(10)) + ';'
                                                FROM Employee_Sector_relationship e2
                                                WHERE e2.Emp_ID = e1.Emp_ID
                                                ORDER BY Sector_ID
                                                FOR XML PATH('') ) AS Sectors
                                                FROM Employee_Sector_Relationship e1
                                                WHERE Emp_ID = {0}
                                                GROUP BY Emp_ID ", dr_SignUp["Emp_ID"]);
                SqlCommand cmd_Sector = new SqlCommand(sql_Sector, sqlConn);
                SqlDataReader dr_Sector = cmd_Sector.ExecuteReader();
                while (dr_Sector.Read())
                {
                    arrSector.Add(dr_Sector["Sectors"].ToString());
                }
                if (arrSector.Count == 0)
                { arrSector.Add(" "); }
                if (arrPhone.Count == 0)
                { arrPhone.Add(" "); }
                //--
                if (arrPhone.Count == 2)
                {
                    PassedGrid.Rows.Add(dr_SignUp["Emp_ID"].ToString(), dr_SignUp["Name"].ToString(), arrSector[0], dr_SignUp["Sum"], arrPhone[0], arrPhone[1]);
                }

                else
                {
                    PassedGrid.Rows.Add(dr_SignUp["Emp_ID"].ToString(), dr_SignUp["Name"].ToString(), arrSector[0], dr_SignUp["Sum"], arrPhone[0]);
                }
            }

        }
        catch (Exception e)
        {
            MessageBox.Show("Error found in SignUpControllerDay..." + Environment.NewLine + e.ToString());
        }
        finally
        {
            if (sqlConn != null)
            {
                sqlConn.Close();
            }
        }
    }

Everything works fine.
Now the real problem. I have been informed that the production SQL server for the application to go live is Microsoft SQL server 2000. After doing a bit research, I came to know that Microsoft server 2000 does not support multiple active results sets propery. In short, it does not allow me to use 2 data readers simultaneously.

I need to know how to read the data from 2 different tables, simultaneously, with regards to SQL Server 2000.

Are there any other ways that i can read data as I have mentioned in the code..

Please help..
the application is almost done and is ready to go to production. but MS server 2000 doesnt allow the applcaition to work accordingly…

please help

  • 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-13T13:01:30+00:00Added an answer on May 13, 2026 at 1:01 pm

    You can have two active datareaders in Sql Server 2000 by simply creating two connections.

    To demonstrate this, I must first berate you for using two very poor practices: dynamic sql and arraylists. Neither have any place in your code. You should also read up on the using construct, though you have my apologies and condolences on “using” and “arraylists” if you’re still using .net 1.1.

    That said, here’s how the code should look:

    string sql_Phone = "SELECT Phone_Number FROM Contact_Details WHERE Emp_ID = @EmpID";
    using (SqlConnection cn2 = new Sqlconnection(databaseConnectionString))
    using (SqlCommand cmd_Phone = new SqlCommand(sql_Phone, cn2))
    {
        cmd_Phone.Parameters.Add("@EmpID", SqlDbType.Int);
        cn2.Open();
    
        while (dr_SignUp.Read())
        {
            List<string> arrPhone = new List<string>();
            cmd_Phone.Parameters[0].Value = dr_SignUp["Emp_ID"];
    
            using (SqlDataReader dr_Phone = cmd_Phone.ExecuteReader())
            {
                while (dr_Phone.Read())
                {
                    arrPhone.Add(dr_Phone["Phone_Number"].ToString());
                }
            }
    

    Also, looking at your code I suspect what you really need to do is re-write your sql. You can combine all those into a single query that you just bind directly to the grid.

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

Sidebar

Ask A Question

Stats

  • Questions 418k
  • Answers 418k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It's ugly, but you could do: ORDER BY CASE invoice_id… May 15, 2026 at 9:55 am
  • Editorial Team
    Editorial Team added an answer OpenGL 1.4 is required for support for automatic mipmap generation… May 15, 2026 at 9:55 am
  • Editorial Team
    Editorial Team added an answer I believe that a compelling reason to do that is… May 15, 2026 at 9:55 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.