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. Visual Basic
  4. Select Top 1

Select Top 1

Scheduled Pinned Locked Moved Visual Basic
csharphelpquestion
7 Posts 5 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.
  • B Offline
    B Offline
    boukaka
    wrote on last edited by
    #1

    I'm creating a report in Microsoft Reporting tool which uses VB.NET (which I don't know very well) I'm trying to select the Top 1 payment type but I can't get the syntax to work. I have =Top 1(Fields!paymenttype.Value) and it's not working, what would the correct expression be in VB.NET to pull the Top record? Thank you for any help!:confused:

    K B L G 4 Replies Last reply
    0
    • B boukaka

      I'm creating a report in Microsoft Reporting tool which uses VB.NET (which I don't know very well) I'm trying to select the Top 1 payment type but I can't get the syntax to work. I have =Top 1(Fields!paymenttype.Value) and it's not working, what would the correct expression be in VB.NET to pull the Top record? Thank you for any help!:confused:

      K Offline
      K Offline
      Kschuler
      wrote on last edited by
      #2

      What kind of an object are you getting the data from? And what version of Visual Studio do you use? If you are using a DataTable you could use dtMyTable.Row(0)("PaymentType") To access the "PaymentType" column in the very first record. dtMyTable.Row(1)("PaymentType") To access the second record, and so on.) If you mean the greatest record, you would have to sort the data first, by which ever column you wish to sort by. You'd have to do the sorting in SQL or by using a DataView control. Does this help?

      1 Reply Last reply
      0
      • B boukaka

        I'm creating a report in Microsoft Reporting tool which uses VB.NET (which I don't know very well) I'm trying to select the Top 1 payment type but I can't get the syntax to work. I have =Top 1(Fields!paymenttype.Value) and it's not working, what would the correct expression be in VB.NET to pull the Top record? Thank you for any help!:confused:

        B Offline
        B Offline
        boukaka
        wrote on last edited by
        #3

        I'm using Visual Studio 2003 and the data is coming from a SQL 2000 table that I am connected to and am pulling data from via a Query Select statement.

        1 Reply Last reply
        0
        • B boukaka

          I'm creating a report in Microsoft Reporting tool which uses VB.NET (which I don't know very well) I'm trying to select the Top 1 payment type but I can't get the syntax to work. I have =Top 1(Fields!paymenttype.Value) and it's not working, what would the correct expression be in VB.NET to pull the Top record? Thank you for any help!:confused:

          L Offline
          L Offline
          Leeland
          wrote on last edited by
          #4

          Can you give us your entire SQL statement. What you have there is invalid.

          1 Reply Last reply
          0
          • B boukaka

            I'm creating a report in Microsoft Reporting tool which uses VB.NET (which I don't know very well) I'm trying to select the Top 1 payment type but I can't get the syntax to work. I have =Top 1(Fields!paymenttype.Value) and it's not working, what would the correct expression be in VB.NET to pull the Top record? Thank you for any help!:confused:

            G Offline
            G Offline
            Guffa
            wrote on last edited by
            #5

            I don't know exactly where you are trying to use the top statement, but it's certainly in the wrong place. The top statement should be placed directly after the select statement: select top 1 ... from ... where ... order by ... --- b { font-weight: normal; }

            B 1 Reply Last reply
            0
            • G Guffa

              I don't know exactly where you are trying to use the top statement, but it's certainly in the wrong place. The top statement should be placed directly after the select statement: select top 1 ... from ... where ... order by ... --- b { font-weight: normal; }

              B Offline
              B Offline
              boukaka
              wrote on last edited by
              #6

              Sorry for the delay, I was at work. What I realized I need is =Max(Fields!paymentcode) Thank you to everyone who responded, I'll try to be clearer next time.

              S 1 Reply Last reply
              0
              • B boukaka

                Sorry for the delay, I was at work. What I realized I need is =Max(Fields!paymentcode) Thank you to everyone who responded, I'll try to be clearer next time.

                S Offline
                S Offline
                shreekar
                wrote on last edited by
                #7

                I know you got the solution - but wanted to point out something - if the ONLY reason you are fetching the data is to get the top payment mode, then you should do it in the Select query and not after ALL the rows are fetched. Shreekar http://shreekarishere.blogspot.com

                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