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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:26:29+00:00 2026-05-30T07:26:29+00:00

I have my mysql query selected fields (item_code, item_name, item quantity, item_selltype, item_selldetail) but

  • 0

I have my mysql query selected fields (item_code, item_name, item quantity, item_selltype, item_selldetail) but some of these fields are variants.

Dim sqlConn As String = ("SELECT item_code, item_name, item_quantity, item_selltype, item_selldetail FROM qa_items")
Dim objDataAdapter As New MySqlDataAdapter(sqlConn, objConn)

I suppose that the query returns:

item_code, item_name, item_quantity, item_selltype, item_selldetail
01         Ball       5              unit           10.52
02         Keyoard    10             unit           50.00
03         Gasoline   5              gallon         70.45

DataGridView control looks so:

Code, Name, Inv, Unit Price, Box Price, Pound Price, Gallon Price

then I need this result in datagridview:

Code, Name,    Inv, Unit Price, Box Price, Pound Price, Gallon Price
01    Ball     5    10.52       0          0            0
02    Keyboard 10   50.00       0          0            0
03    Gasoline 5    0           0          0            70.45

I searched in many ways some code that can do this but I can not succeed, help..

  • 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-30T07:26:31+00:00Added an answer on May 30, 2026 at 7:26 am

    I think you need a translator object. Get your data from the database, and use it to populate a List<> of something like this:

    class Item
    {
        public int Code { get; private set; }
        public string Name { get; private set; }
        public int Inv { get; private set; }
        [DisplayName("Unit Price")]
        public double UnitPrice { get; private set; }
        [DisplayName("Box Price")]
        public double BoxPrice { get; private set; }
        [DisplayName("Pound Price")]
        public double PoundPrice { get; private set; }
        [DisplayName("Gallon Price")]
        public double GallonPrice { get; private set; }
    
        public Item(int item_code, string item_name, int item_quantity, string item_selltype, double item_selldetail)
        {
            Code = item_code;
            Name = item_name;
            Inv = item_quantity;
            UnitPrice = 0;
            BoxPrice = 0;
            PoundPrice = 0;
            GallonPrice = 0;
            switch (item_selltype)
            {
                case "unit": UnitPrice = item_selldetail; break;
                case "box": BoxPrice = item_selldetail; break;
                case "pound": PoundPrice = item_selldetail; break;
                case "gallon": GallonPrice = item_selldetail; break;
                default: throw new InvalidExpressionException();
            }
        }
    }
    

    Then set the DataSource of the grid to that List<Item>.

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

Sidebar

Related Questions

I have a MySQL query like this: SELECT *, SUM(...some SQL removed for brevety)
I have a mysql query that shows the users last viewed documents. Some sort
I have read the topic Mysql query: retrieve current date query ., but my
I need to have MySQL query like this one: UPDATE table_name SET 1 =
I have a MySQL query that returns a result with a single column of
I have a MySQL query in which I want to include a list of
I have a MySQL query that I use to retrieve random rows from a
I have a MySQL query like this: SELECT DAYNAME(CreatedAt) AS TheDay, SUM(Amount) AS TheSum
I have a mysql query that targets a single column in a single row
I have a MySQL query where I would like it to have a pseudo

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.