Results 1 to 7 of 7

Thread: Operations in dataset, or database?

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2008
    Posts
    57

    Operations in dataset, or database?

    Hello, I have an xls file, with 10 columns.
    I want to pass the data to mysql.
    My problem is that I shall find, sum of each row, max, min, average etc.
    And I don't know how to do it.
    When the data are filled to the dataset, and if this is the right solusion, how should I do this?
    I can't find a way to work with rows.
    OR fill my database, and do that operations with queries?
    Thanks a lot

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Operations in dataset, or database?

    Once you've populated a DataTable you can call its Compute method to perform aggregations like that, e.g.
    vb.net Code:
    1. Dim min As Integer = CInt(myDataTable.Compute("MIN(SomeColumn)")
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Member
    Join Date
    Feb 2008
    Posts
    57

    Re: Operations in dataset, or database?

    first of all thanks for bothering.
    I have mentioned although that I want to work with rows, not columns.
    I have tried this method already.

  4. #4
    Fanatic Member
    Join Date
    Jun 2004
    Location
    All useless places
    Posts
    917

    Re: Operations in dataset, or database?

    Quote Originally Posted by manin
    My problem is that I shall find, sum of each row, max, min, average etc.
    When do you want to do this? Is it required in the same screen where you are importing data from Excel to MySQL or is it a 2 step process?
    Like: Step1: Import all Excel data to MySQL
    Step2: Show the aggregated values on another screen (fetching values from the MySQL and not excel).

  5. #5

    Thread Starter
    Member
    Join Date
    Feb 2008
    Posts
    57

    Re: Operations in dataset, or database?

    I want the most easy and quick way.
    I think the best is to import data to datatable, find the values I need,
    and then export all data (excel and sum, min etc) to mysql.

    If this cannot be done, then I should, follow your suggestion.

  6. #6
    Fanatic Member
    Join Date
    Jun 2004
    Location
    All useless places
    Posts
    917

    Re: Operations in dataset, or database?

    What you want can be done, I was not suggesting it can't be. But DataSet was built to replicate a bit of RDBMS that are all set based (or column based).
    If you want to perform all those functions on a row-by-row basis then your only option is to iterate through all rows do the calculation and then export those values to MySQL.

    It may also give a better idea to others if you provide some sample data. Something like below

    As stored in DataTable:
    Col1 Col2 Col3...
    Name1 15 20
    Name2 32 11
    Name3 22 54 & so on.

    As you want to store in MySQL
    Name Avg Max...
    Name1 17.5 20
    Name2 21.5 32
    Name3 38 54


    This gives a better visual idea of what you are trying to achieve.

  7. #7

    Thread Starter
    Member
    Join Date
    Feb 2008
    Posts
    57

    Re: Operations in dataset, or database?

    Quote Originally Posted by rjv_rnjn View Post

    It may also give a better idea to others if you provide some sample data.
    I will spend a few days more, searching a good solution, and I let you know

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width