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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:50:11+00:00 2026-05-16T22:50:11+00:00

I am currently working on a project in C# and use MySql as database.

  • 0

I am currently working on a project in C# and use MySql as database. I am currently having a problem with creating a custom DataTable I want to show in my Report.
Extra Info : A test can have any no combinations of Cells & Valves for a test
But for one test it uses set range of Vales and Cells are predefined before each test.

Results Table (Sample)

 TestID | CellID | ValveID | OutputValue1| OutputValue2 |
1       | 1      | 1       | 2.5         | 0.12         |
1       | 1      | 1       | 2.5         | 0.12         |
1       | 1      | 2       | 2.8         | 0.13         |
1       | 2      | 1       | 3.2         | 0.12         |
1       | 2      | 2       | 3.5         | 0.12         |
1       | 2      | 4       | 4.1         | 0.14         |

So for a example Valve 3 is not tested at this particular example. But can use if wanted.
Basically my table rows are dynamically need generate based on this results table.

Report Expected

Test ID = 1
                     Valves
       |     1     |     2     |     4     |
CellID |Out1 | Out2| Out1| Out2|Out1 | Out2|
1      | 2.5 | 0.12| 2.8 | 0.13| 2.9 | 0.12|  
2      | 3.2 | 0.12| 3.5 | 0.12| 4.1 | 0.14|

Out1 = OutputValue1
Out2 = OutputValue2
Can any one help me by direct me to a good link or explanation how to get this kind dynamic Data Table

  • 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-16T22:50:12+00:00Added an answer on May 16, 2026 at 10:50 pm

    Try this sql code. I have recreated a dummy table resembling your original table. There is a UDF that needs to be created as well. The remaining code can go in as a part of stored proc.

    set xact_abort on
    begin tran
    CREATE TABLE TestTable
    (
    TestId int not null,
    CellId int not null,
    valveid int not null,
    op1 numeric(5,2) not null,
    op2 numeric (5,2) not null
    )
    go
    
    CREATE FUNCTION GetOutputString
    (
    @TestId INT,
    @CellId INT
    )
    RETURNS VARCHAR(1000)
    AS
    BEGIN
        DECLARE @output VARCHAR(1000)
        SELECT @output = ISNULL(@output + ';','')
                         +
                         CAST(valveid AS VARCHAR(5)) + '#'
                         +
                         CAST(op1 as VARCHAR(10))+ ','
                         +
                         CAST(op2 as VARCHAR(10))
          FROM TestTable
         WHERE TestId = @testid
           AND cellid = @cellid
    
         RETURN @output
    END
    go
    -- insert dummy data
    INSERT INTO TestTable
    SELECT 1, 1, 1, 2.5, .12
    UNION
    SELECT 1, 1, 2, 2.8, .13
    UNION
    SELECT 1, 2, 1, 3.2, .12
    UNION
    SELECT 1, 2, 2, 3.5, .12
    UNION
    SELECT 1, 2, 4, 4.5, .13
    
    -- create temp table/table variable depending on the size of the actual table.
    DECLARE @tmp TABLE (
    TestId int not null,
    CellId int not null,
    OutputString VARCHAR(1000) null
    )
    
    INSERT INTO @tmp (TestId, CellId)
    SELECT TestId, CellId
    FROM TestTable
    GROUP BY TestId,CellId
    
    UPDATE @tmp
       SET OutputString = dbo.GetOutputString(TestId, CellId)
    
    SELECT * FROM @tmp
    rollback
    

    What it does is it returns a semicolon-separated values of output values for each valveid.
    Of course in the front end, you’ll have to write code that identifies valveid as the number between a semicolon (;) and a hash(#).
    Here is the output that the above SQL produces:

    1   1   1#2.50,0.12;2#2.80,0.13
    1   2   1#3.20,0.12;2#3.50,0.12;4#4.50,0.13
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently working on a project that makes use of Seam/Hibernate (JPA) on MySQL.
I am currently working on a project where I want to use the Entity
I'm currently working on a project where I use Zend Framework with Propel. I'm
I am currently working on Project Euler for fun, and use Haskell for practicing.
Our team is currently working on a large project which makes heavy use of
I am currently working on a SharePoint project that needs to use the Lists
I am currently working on android project where I am using a custom list
I'm currently working on a project were we use freemarker as a template language.
I'm currently working on project euler problem 14 . I solved it using a
I am currently working on a project that requires the use of SVN on

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.