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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:27:22+00:00 2026-05-28T04:27:22+00:00

i have windows application in which i am constructing dataset with two datatables one

  • 0

i have windows application in which i am constructing dataset with two datatables one is “Products” and other is “TaxView”.I have included sample code below.in this code i am getting error Input array is longer than the number of columns in this table

 public DataTable[] getProductViewDetails(ArrayList ssd,ArrayList tax)
        {
            DataTable Products = new DataTable();
            DataColumn SalesDetailID = Products.Columns.Add("SalesDetailID", typeof(System.INT32));
            DataColumn BrandName = Products.Columns.Add("BrandName", typeof(System.String));
            DataColumn ProductName = Products.Columns.Add("ProductName", typeof(System.String));
            DataColumn Quantity = Products.Columns.Add("Quantity", typeof(System.INT32));
            DataColumn Rate = Products.Columns.Add("Rate", typeof(System.INT32));
            DataColumn Per = Products.Columns.Add("Per", typeof(System.String));
            DataColumn Discount = Products.Columns.Add("Discount", typeof(System.String));


            DataTable TaxView = new DataTable();
            DataColumn SalesTaxDetailID = Products.Columns.Add("SalesTaxDetailID", typeof(System.Int32));
            DataColumn TaxAmt = Products.Columns.Add("TaxAmt", typeof(System.Int32));
            DataColumn Total = Products.Columns.Add("Total", typeof(System.Int32));
            DataColumn TaxDesc = Products.Columns.Add("TaxDesc", typeof(System.String));
            DataColumn TaxValues = Products.Columns.Add("TaxValues", typeof(System.INT32));

            foreach (SalesStructDetails s in ssd)
            {
                //int previoustaxdetail;

                Products.Rows.Add(1,HP, Printer, 2, 2100, pcs, 125);

                foreach (TaxDetail t in tax)
                {                                       
                    if (s.SalesDetailId == t.SalesDetailID)
                    {
                        TaxView.Rows.Add(1, 125, 75, VAT, 4);

                    }
                }
            }

            DataTable[] dt = new DataTable[2] { Products, TaxView };
            return dt;
        }

i am getting error at the line TaxView.Rows.Add(1, 125, 75, VAT, 4);

  • 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-28T04:27:23+00:00Added an answer on May 28, 2026 at 4:27 am

    Look carefully – you are adding the tax column definitions to the products table. Add them to the tax table instead. Example:

    DataTable TaxView = new DataTable();
    DataColumn SalesTaxDetailID = Products.Columns.Add(blah);
    

    Should be;

    DataTable TaxView = new DataTable();
    DataColumn SalesTaxDetailID = TaxView.Columns.Add(blah);
    

    Also: consider using regular classes rather than DataTable

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

Sidebar

Related Questions

I have two windows application, one is a windows service which create EventWaitHandle and
Hai every one I am developing an windows application in which i have to
I have an application which was developed under Windows, but for gcc. The code
I have a Windows (XP) application which needs to display a two-dimensional rectangle within
I have developed a Windows application which has one DataGrid. I am assigning Defaultview
I have a Windows application which has a browser in it. The Windows application
I have a Windows Service application which uses a Threading.Timer and a TimerCallback to
I have a C# windows application which does the following: 1) the main form
I have a windows service application which works using remoting. It is used to
i have a windows application made in VB.NET which maintains a database, and i

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.