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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:00:39+00:00 2026-06-14T02:00:39+00:00

Seeking help from friends I have loaded 3 tables from database to DataSet using

  • 0

Seeking help from friends

I have loaded 3 tables from database to DataSet using DataReader but I’m unable to bind it to a GridView.

protected void GetStudReport(Object o, EventArgs e)
{
    if (mycon.State != ConnectionState.Open)
    {
        List<string> lstQstn = new List<string>();

        mycon.Open();
        cmd = new MySqlCommand("SELECT * from scord_mark_table where stu_ID=@StID", mycon);
        cmd.Parameters.Add(new MySqlParameter("StID", MySqlDbType.VarChar, 10, "stu_ID"));
        cmd.Parameters["@StID"].Value = drpDnSearch3.SelectedValue;
        MySqlDataReader rdr1 = cmd.ExecuteReader();
        DataSet ds = new DataSet();
        DataTable dtScrTbl = new DataTable("ScoreTable");
        dtScrTbl.Load(rdr1);
        ds.Tables.Add(dtScrTbl);
        rdr1.Close();
        cmd = null;

        int i = 0;
        Dictionary<string, string> dctSub = new Dictionary<string, string>();
        using (DataTableReader dtr = ds.CreateDataReader())
        {
            while (dtr.Read())
            {
                lstQstn.Add(dtr["test_id"].ToString());

                while (i <= lstQstn.Count())
                {
                    cmd = new MySqlCommand("SELECT test_id,subject_id from qution_no_table where test_id='" + lstQstn[i].ToString() + "'", mycon);
                    MySqlDataReader rdr2 = cmd.ExecuteReader();
                    while (rdr2.Read())
                    {
                      dctSub.Add(rdr2["subject_id"].ToString(),rdr2["test_id"].ToString());
                    }
                    rdr2.Close();
                    break;
                }

                i++;


            }
            cmd = null;
        }

        string strTestID="where test_id='";
        i=0;
        foreach (string lst in lstQstn)
        {
            if (i > 0)
            {
                strTestID += @" and test_id='";
            }
            strTestID += lst + @"'";
            i++;
        }


        cmd = new MySqlCommand("SELECT * from qution_no_table " +strTestID+";"+"SELECT * from out_of_mark_table " +strTestID, mycon);

        MySqlDataReader rdr3 = cmd.ExecuteReader();

        DataTable dtQNoTbl = new DataTable("QstNoTable");
        dtQNoTbl.Load(rdr3);
        ds.Tables.Add(dtQNoTbl);

        rdr3.NextResult();

        // bind the second resultset
        DataTable dtOutMrkTbl = new DataTable("OutOfMarkTable");
        dtOutMrkTbl.Load(rdr3);
        ds.Tables.Add(dtOutMrkTbl);
        rdr3.Close();

        //**
        GridView1.DataSource = ds.Tables["OutOfMarkTable"];
        GridView1.DataBind(); //**
     }
}
  • 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-14T02:00:41+00:00Added an answer on June 14, 2026 at 2:00 am

    The reason is your rdr3.NextResult() which advances the reader to the next result(if any). But that is already done in DataTable.Load. From MSDN:

    The Load method consumes the first result set from the loaded
    IDataReader, and after successful completion, sets the reader’s
    position to the next result set, if any.

    So you simply need to omit it. Another option is to use DatSet.Load(reader) instead to add the last two tables at once:

    ds.Load(rdr, LoadOption.OverwriteChanges, "QstNoTable","OutOfMarkTable");
    GridView1.DataSource = ds.Tables["OutOfMarkTable"]; 
    

    DataSet.Load will not remove existing tables in the DataSet.

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

Sidebar

Related Questions

I am newbie in Ruby.. seeking some help.. I have a code DB =
I need some help writing a SQL statement. I have two tables in a
I am seeking help from SOA/ESB experts on some architectural design. Apologies if the
Seeking help from Nginx experts here. I want to block people accessing CSS or
I have a very simple issue with datetime and am seeking some help. I
Seeking some basic help, probably a typo in code. I have the following: create
i want your help very badly..bcz i am seeking an answer for this from
I am seeking help, most importantly from VMEbus experts. I am working on a
i am seeking help on updating one column in a table with results from
new to JavaScript seeking some help. I have a form with a select drop

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.