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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:13:47+00:00 2026-06-13T17:13:47+00:00

While running the code it is giving error Cannot find column [max] . but

  • 0

While running the code it is giving error ” Cannot find column [max].” but i have added the max and min column to the table in the dataset

MySql.Data.MySqlClient.MySqlConnection mycon = new MySqlConnection(GetConnectionString());
    if (mycon.State != ConnectionState.Open)

        {

            string sqlCat = "SELECT * FROM out_of_mark_table";
            string sqlProd = "SELECT * FROM scord_mark_table";

            MySqlDataAdapter da = new MySqlDataAdapter(sqlCat, mycon);
            DataSet ds = new DataSet();

            try
            {
                mycon.Open();
                da.Fill(ds, "out_of_mark_table");

                da.SelectCommand.CommandText = sqlProd;
                da.Fill(ds, "scord_mark_table");
            }
            finally
            {
                mycon.Close();
            }

            DataRelation relat = new DataRelation("CatProds", ds.Tables["out_of_mark_table"].Columns["test_id"], ds.Tables["scord_mark_table"].Columns["test_id"]);
            ds.Relations.Add(relat);

            DataColumn count = new DataColumn("Products (#)", typeof(int), "COUNT(Child(CatProds).test_id)");
            DataColumn max = new DataColumn("Most Expensive Product", typeof(decimal), "MAX(Child(CatProds).total)");
            DataColumn min = new DataColumn("Least Expensive Product", typeof(decimal), "MIN(Child(CatProds).total)");
            DataColumn no=new DataColumn("No");
            DataColumn IdCol = new DataColumn();
            min.Caption = "min";
            max.Caption = "max";
            string expr = "max * min";

            IdCol.ColumnName = "ID";
            IdCol.DataType = Type.GetType("System.Int32");
            IdCol.ReadOnly = true;
            IdCol.AllowDBNull = false;
            //IdCol.Unique = true;
            IdCol.AutoIncrement = true;
            IdCol.AutoIncrementSeed = 1;
            IdCol.AutoIncrementStep = 1;



            ds.Tables["out_of_mark_table"].Columns.Add(count);
            ds.Tables["out_of_mark_table"].Columns.Add(max);
            ds.Tables["out_of_mark_table"].Columns.Add(min);
            ds.Tables["out_of_mark_table"].Columns.Add(IdCol);
            DataColumn sum = new DataColumn("Sum of", typeof(int), expr, MappingType.Attribute);
            **ds.Tables["out_of_mark_table"].Columns.Add(sum);**
            IdCol.SetOrdinal(0);
            GridView1.DataSource = ds.Tables["out_of_mark_table"];
            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-13T17:13:49+00:00Added an answer on June 13, 2026 at 5:13 pm

    You have set the captions to “Max” and “Min”, but the DataColumns's identifier is it’s Ordinal or ColumnName. You have set the ColumnName via constructor to

    "Most Expensive Product" and "Least Expensive Product"

    So use

    string expr = "[Most Expensive Product] * [Least Expensive Product]";
    

    instead.

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

Sidebar

Related Questions

While I am running this code it showing me a following error:- Column 'virtuemart_product_id'
While running code in production, I don't have to interact with the Ember.js runloop
While running the code I've included below I receive the error EntityCommandExecutionException was unhandled
I have some debugging code that if executed while running with GBD attached should
while running: rake snorby:setup getting below error: rake aborted! You have already activated rake
I am getting the following error while running the code, Warning: require_once(product.php) [function.require-once]: failed
I have this code which is giving the error: error this boost::lock_error error this
I am getting this error While running this LoadError: Expected /home/user/Desktop/Tripurari/myapp/app/models/host.rb to define Host##
I got the following error while running my perl script with the negative lookaround
I am using the following code. While running in localhost it gives correctly the

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.