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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:10:45+00:00 2026-05-28T14:10:45+00:00

I need sub comments to be just below comments I tried in the below

  • 0

I need sub comments to be just below comments I tried in the below manner and it could able to retrieve only first main comment and all its sub comments but couldn’t load from second main comments. The logic I used is

            MyConnection.Open();
            OdbcCommand cmd = new OdbcCommand("Select * from maincomments", MyConnection);
            OdbcDataReader dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                string abc1 = dr[0].ToString();
                string abc2 = dr[1].ToString();
                string abc3 = dr[2].ToString();
                string abc4 = dr[3].ToString();
                string abc5 = dr[4].ToString();
                string abc6 = dr[5].ToString();
                string abc7 = dr[6].ToString();

                maincomm.Controls.Add(new LiteralControl(abc2 + "<br />" + abc5 + "<br />"));
                cmd = new OdbcCommand("Select * from subcomments where acc_id=?", MyConnection);
                cmd.Parameters.Add("@email", OdbcType.BigInt, 20).Value = abc1;
                dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    string abcd1 = dr[0].ToString();
                    string abcd2 = dr[1].ToString();
                    string abcd3 = dr[2].ToString();
                    string abcd4 = dr[3].ToString();
                    string abcd5 = dr[4].ToString();
                    string abcd6 = dr[5].ToString();
                    string abcd7 = dr[6].ToString();
                    string abcd8 = dr[7].ToString();
                    maincomm.Controls.Add(new LiteralControl(abcd3 + "<br />" + abcd6 + "<br />"));
                }
            }
            MyConnection.Close();

In the above code acc_id is serial number of maincomments.

What’s wrong in my code?

  • 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-28T14:10:47+00:00Added an answer on May 28, 2026 at 2:10 pm

    While you are using dr to get comments, in the inner loop you overwrite it with the DataReader for getting sub-comments.

    You should use different variables for the two (e.g. drComments and drSubComments)

    That’s what looks wrong from a functional point of view. My opinion is that there are still some more improvements to be done. After you fix the code I strongly suggest to post this code on CodeReview to get some good advices on how to refactor it.

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

Sidebar

Related Questions

I need to copy a node and its sub-nodes: first: one identical copy followed
A python script need to spawn multiple sub-processes via fork(). All of those child
I need to implement an MVC site with urls per below: category1/product/1/wiki category1/product/2/wiki category1/sub-category2/product/3/wiki
I need to replace many different sub-string in a string in the most efficient
i need to refresh combo box (sub category ) related to what i choose
I need to pass a regex substitution as a variable: sub proc { my
I need to ensure 2 calls are enlisted in a transaction Sub InsertOrder(order) ...insert
I want to (need to) start a sub-process from a perl script that checks
I'm using iReport and I need to create a sub-report using a XML DataSource
I have a situation where I need to ignore parts of page load sub

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.