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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:49:17+00:00 2026-06-18T01:49:17+00:00

try { String empid1 = Request.QueryString[MyText]; int empid = int.Parse(empid1); string constr = System.Configuration.ConfigurationManager.ConnectionStrings[EmployeeDatabase].ConnectionString;

  • 0
try
        {
            String empid1 = Request.QueryString["MyText"];

            int empid = int.Parse(empid1);
            string constr = System.Configuration.ConfigurationManager.ConnectionStrings["EmployeeDatabase"].ConnectionString;
            SqlConnection con = new SqlConnection(constr);
            con.Open();
            SqlCommand cmd = new SqlCommand("ReportingManagers", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@EmpID", SqlDbType.Int, 0).Value = empid;

            SqlDataReader dr = cmd.ExecuteReader();
            dr.Read();
            LinkButton3.Text = string.Empty;
            int i = 1;
             while(dr.Read())
            {


                TreeNode parentNode = new TreeNode("L" + i++ + "Manager : " + dr["Emp_Name"].ToString());
                parentNode.Value = dr["Emp_ID"].ToString();
                TreeView1.Nodes.Add(parentNode);
                parentNode.ChildNodes.Add(new TreeNode("Short ID : " + dr["Short_ID"].ToString()));
                parentNode.ChildNodes.Add(new TreeNode("EmpID : " + dr["Emp_ID"].ToString()));
              //  LinkButton3.Text = "Reporting Managers";  
            }

             DataTable dt = new DataTable();
             dt.Load(dr);
             if (dt.Rows.Count > 1)
             {
                 LinkButton3.Text = "Reporting Managers";  
             }

            dr.Close();
            con.Close();
        }

Please explain me why my if loop is not getting executed in the above code. I can see that in datatable dt I got row count ‘0’ but my dr is showing true for has rows..I dont wnat to use sql adapter in this scenerio.

How can i capture row count of data table in this scenario?

  • 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-18T01:49:19+00:00Added an answer on June 18, 2026 at 1:49 am

    You can’t load a datatable with a datareader that has already been used to the end of its data.
    Try to change the order of your code execution in this way

    SqlDataReader dr = cmd.ExecuteReader();
    LinkButton3.Text = string.Empty;
    int i = 1;
    DataTable dt = new DataTable();
    dt.Load(dr);
    if (dt.Rows.Count > 1)
    {
        LinkButton3.Text = "Reporting Managers";  
        foreach(DataRow r in dt.Rows)
        {
            TreeNode parentNode = new TreeNode("L" + i++ + "Manager : " + r["Emp_Name"].ToString());
            parentNode.Value = r["Emp_ID"].ToString();
            TreeView1.Nodes.Add(parentNode);
            parentNode.ChildNodes.Add(new TreeNode("Short ID : " + r["Short_ID"].ToString()));
            parentNode.ChildNodes.Add(new TreeNode("EmpID : " + r["Emp_ID"].ToString()));
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have database code like this try { string strConnectionString = ConfigurationManager.ConnectionStrings[SqlServerCstr].ConnectionString; SqlConnection myConnection
how use Runtime.getRuntime().exec()? I try: try { String[] callAndArgs = {path\\program.exe,arg1,arg2,arg3} System.out.println(before); Process p
private static void deleteProxy(File proxyOld, String host, int port) { try { String lines,
try { String s1 = example@gmail.com; //sender (from) String s2 = request.getParameter(email);// (from jsp
My code: public void postOnWall(String msg) { try { String response = facebookClient.request(me); Bundle
try{ String query= select user_name from user; ResultSet rs = queries.performQuery(query); while(rs.next()){ System.out.println(User Name
My Code is try { string mtellThemePath = ConfigurationManager.AppSettings[mtellThemePath] == null ? Server.MapPath(~/App_Themes/) :
final String message[] = {,,}; try{ String UID = null, UBAL = null; DateFormat
In my program I generate classes dynamically but when I try: String[] args =
I try use string as a regular expression pattern but I've following errors PHP

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.