Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Return Multiple Rows of the same Student Id (PK)

Return Multiple Rows of the same Student Id (PK)

Scheduled Pinned Locked Moved C#
question
10 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    ferronrsmith
    wrote on last edited by
    #1

    i created a form, but later noticed that i have four rows of student data for 1 ID, how do i bring back the four rows of data?

    Ferron

    C H W 3 Replies Last reply
    0
    • F ferronrsmith

      i created a form, but later noticed that i have four rows of student data for 1 ID, how do i bring back the four rows of data?

      Ferron

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Your DB is obviously broken. You can do a select to get the four rows, but if they have the same Id, then you have a bigger issue.

      Christian Graus Driven to the arms of OSX by Vista.

      F 1 Reply Last reply
      0
      • C Christian Graus

        Your DB is obviously broken. You can do a select to get the four rows, but if they have the same Id, then you have a bigger issue.

        Christian Graus Driven to the arms of OSX by Vista.

        F Offline
        F Offline
        ferronrsmith
        wrote on last edited by
        #3

        they have the same id, but different addresses, so i wanna be able to print all those addresses

        Ferron

        1 Reply Last reply
        0
        • F ferronrsmith

          i created a form, but later noticed that i have four rows of student data for 1 ID, how do i bring back the four rows of data?

          Ferron

          H Offline
          H Offline
          Herman T Instance
          wrote on last edited by
          #4

          is it the way you (outer) join the data in SQL? Could you post your query

          F 1 Reply Last reply
          0
          • H Herman T Instance

            is it the way you (outer) join the data in SQL? Could you post your query

            F Offline
            F Offline
            ferronrsmith
            wrote on last edited by
            #5

            set ANSI_NULLS ON
            set QUOTED_IDENTIFIER ON
            GO
            ALTER PROCEDURE [dbo].[sp_getTransfer] (@TRANSFER_ID int) AS
            -- Declare variables
            DECLARE @rc Int
            SELECT TransferDetails.IMID,TransferDetails.[DESCRIPTION], TransferDetails.AMOUNT,TRANSFERS.AMOUNT_TRANSFER, TRANSFERS.CONSIDERATION, TRANSFERS.TRANSFER_ID,
            TRANSFERS.[DATE], TransferDetails.CURR, CUSTOMERS.CMF_NAME_1, CUSTOMERS.CMF_NAME_2,
            CUSTOMERS.CMF_ADDR_1, CUSTOMERS.CMF_ADDR_2, CUSTOMERS.CMF_ADDR_3, CUSTOMERS.CMF_ADDR_4,
            CUSTOMERS.CMF_POSTAL_CODE, TRANSFERS.Cons_Curr
            FROM
            ("FGBInvestment"."dbo"."TransferDetails" "TransferDetails" INNER JOIN "FGBInvestment"."dbo"."TRANSFERS" "TRANSFERS" ON "TransferDetails"."TRANSFER_ID"="TRANSFERS"."TRANSFER_ID") INNER JOIN "FGBInvestment"."dbo"."CUSTOMERS" "CUSTOMERS" ON "TRANSFERS"."CUSTODIAN"="CUSTOMERS"."CMF_ACCOUNT"
            WHERE "TRANSFERS"."TRANSFER_ID"= @TRANSFER_ID

            Ferron

            1 Reply Last reply
            0
            • F ferronrsmith

              i created a form, but later noticed that i have four rows of student data for 1 ID, how do i bring back the four rows of data?

              Ferron

              W Offline
              W Offline
              Wendelius
              wrote on last edited by
              #6

              I had a look at your query and it seems fine. When you say that you have 4 rows for the same customer ID, do you mean that "CUSTOMERS"."CMF_ACCOUNT" has the same value? If that's your key column (is it appears to be based on the query), I think your data is corrupted. If that's the key column of customers, it should be either primary key or unique key and there would be no duplicates.

              The need to optimize rises from a bad design.My articles[^]

              F 1 Reply Last reply
              0
              • W Wendelius

                I had a look at your query and it seems fine. When you say that you have 4 rows for the same customer ID, do you mean that "CUSTOMERS"."CMF_ACCOUNT" has the same value? If that's your key column (is it appears to be based on the query), I think your data is corrupted. If that's the key column of customers, it should be either primary key or unique key and there would be no duplicates.

                The need to optimize rises from a bad design.My articles[^]

                F Offline
                F Offline
                ferronrsmith
                wrote on last edited by
                #7

                When i run the query i found that there was a record with 4 different IMID, but the same transfer_id, i want to print those four records on to my form (aspx page)

                Ferron

                W 1 Reply Last reply
                0
                • F ferronrsmith

                  When i run the query i found that there was a record with 4 different IMID, but the same transfer_id, i want to print those four records on to my form (aspx page)

                  Ferron

                  W Offline
                  W Offline
                  Wendelius
                  wrote on last edited by
                  #8

                  Based on your query, IMID is a column in TranferDetails and Tranfser_ID is the key column for Transfers, correct? So if you have four rows in TransferDetails for a single transfer_ID, this query will result to four rows. Isn't this what you got when running the query? I'm bit confused since if the situation described above is what you are experiencing, I don't see where the problem is. Or is the problem that your query actually returns four rows, but you're unable to show them simultaneously on aspx page?

                  The need to optimize rises from a bad design.My articles[^]

                  F 1 Reply Last reply
                  0
                  • W Wendelius

                    Based on your query, IMID is a column in TranferDetails and Tranfser_ID is the key column for Transfers, correct? So if you have four rows in TransferDetails for a single transfer_ID, this query will result to four rows. Isn't this what you got when running the query? I'm bit confused since if the situation described above is what you are experiencing, I don't see where the problem is. Or is the problem that your query actually returns four rows, but you're unable to show them simultaneously on aspx page?

                    The need to optimize rises from a bad design.My articles[^]

                    F Offline
                    F Offline
                    ferronrsmith
                    wrote on last edited by
                    #9

                    yes man, that's exactly what i want too do, thank you man, thank you. Can you show me how ? an example maybe?

                    Ferron

                    W 1 Reply Last reply
                    0
                    • F ferronrsmith

                      yes man, that's exactly what i want too do, thank you man, thank you. Can you show me how ? an example maybe?

                      Ferron

                      W Offline
                      W Offline
                      Wendelius
                      wrote on last edited by
                      #10

                      I'm sorry but if the problem is in the aspx, that's something where I'm not able to help you. I suggest that you try ASP.NET[^]-forum. I believe you would get good answers from there.

                      The need to optimize rises from a bad design.My articles[^]

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups