Difference between getrows and getstring

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Crane Linkledder

    Difference between getrows and getstring


    What is the difference, and when to use one over the other?

    Thanks


  • Aaron Bertrand - MVP

    #2
    Re: Difference between getrows and getstring

    GetRows() is typically used when you still need to do row-by-row processing,
    or you need to refer to certain members in the set individually.

    GetString() is useful when you need a formatted string that has simple
    determinations for what goes between a "row" and "column" (e.g. not too much
    complex iteration or conditional logic, like when alternating row colors for
    display)... see one usage here: http://www.aspfaq.com/2482

    For more comparison stuff, see http://www.aspfaq.com/2467

    A



    "Crane Linkledder" <Linkledder@NOT ADOMAIN.com> wrote in message
    news:uLcl$omnDH A.3612@TK2MSFTN GP11.phx.gbl...[color=blue]
    >
    > What is the difference, and when to use one over the other?
    >
    > Thanks
    >
    >[/color]


    Comment

    • Ray at

      #3
      Re: Difference between getrows and getstring

      GetRows returns a two dimensional array of the recordset. GetString returns
      your records all concatenated together with some other text in between, if
      you choose.

      Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.

      Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.


      Ray at work

      "Crane Linkledder" <Linkledder@NOT ADOMAIN.com> wrote in message
      news:uLcl$omnDH A.3612@TK2MSFTN GP11.phx.gbl...[color=blue]
      >
      > What is the difference, and when to use one over the other?
      >
      > Thanks
      >
      >[/color]


      Comment

      • Crane Linkledder

        #4
        Re: Difference between getrows and getstring



        Thanks to the both of you. One last question. When using getrows, is it
        possible to exclude specific columns?

        I am selecting more columns in my SELECT statement than I'd like to display
        on screen. How can I filter them out?

        Thanks




        "Crane Linkledder" <Linkledder@NOT ADOMAIN.com> wrote in message
        news:uLcl$omnDH A.3612@TK2MSFTN GP11.phx.gbl...[color=blue]
        >
        > What is the difference, and when to use one over the other?
        >
        > Thanks
        >
        >[/color]


        Comment

        • Bob Barrows

          #5
          Re: Difference between getrows and getstring

          Crane Linkledder wrote:[color=blue]
          > Thanks to the both of you. One last question. When using getrows, is
          > it possible to exclude specific columns?
          >[/color]
          The documentation is here:
          Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.


          As you will see, you can supply an " ... array of field names or ordinal
          position numbers" in the third argument. So if you wanted to only use the
          first, third and fifth fields in the recordset, you could do this:

          arResults = rs.GetRows(,,ar ray(0,2,4))

          The MSDN Library is your friend.

          HTH,
          Bob Barrows

          --
          Microsoft MVP -- ASP/ASP.NET
          Please reply to the newsgroup. The email account listed in my From
          header is my spam trap, so I don't check it very often. You will get a
          quicker response by posting to the newsgroup.


          Comment

          • Crane Linkledder

            #6
            Re: Difference between getrows and getstring

            I'm sorry. I meant getString. Is this true with getString also?


            "Bob Barrows" <reb01501@NOyah oo.SPAMcom> wrote in message
            news:uFz$tfnnDH A.2216@TK2MSFTN GP12.phx.gbl...[color=blue]
            > Crane Linkledder wrote:[color=green]
            > > Thanks to the both of you. One last question. When using getrows, is
            > > it possible to exclude specific columns?
            > >[/color]
            > The documentation is here:
            > http://msdn.microsoft.com/library/en...damth02_10.asp
            >
            > As you will see, you can supply an " ... array of field names or ordinal
            > position numbers" in the third argument. So if you wanted to only use the
            > first, third and fifth fields in the recordset, you could do this:
            >
            > arResults = rs.GetRows(,,ar ray(0,2,4))
            >
            > The MSDN Library is your friend.
            >
            > HTH,
            > Bob Barrows
            >
            > --
            > Microsoft MVP -- ASP/ASP.NET
            > Please reply to the newsgroup. The email account listed in my From
            > header is my spam trap, so I don't check it very often. You will get a
            > quicker response by posting to the newsgroup.
            >
            >[/color]


            Comment

            • Chris Hohmann

              #7
              Re: Difference between getrows and getstring

              "Crane Linkledder" <Linkledder@NOT ADOMAIN.com> wrote in message
              news:%231bvGlnn DHA.1296@TK2MSF TNGP09.phx.gbl. ..[color=blue]
              > I'm sorry. I meant getString. Is this true with getString also?
              >
              >
              > "Bob Barrows" <reb01501@NOyah oo.SPAMcom> wrote in message
              > news:uFz$tfnnDH A.2216@TK2MSFTN GP12.phx.gbl...[color=green]
              > > Crane Linkledder wrote:[color=darkred]
              > > > Thanks to the both of you. One last question. When using getrows,[/color][/color][/color]
              is[color=blue][color=green][color=darkred]
              > > > it possible to exclude specific columns?
              > > >[/color]
              > > The documentation is here:
              > > http://msdn.microsoft.com/library/en...damth02_10.asp
              > >
              > > As you will see, you can supply an " ... array of field names or[/color][/color]
              ordinal[color=blue][color=green]
              > > position numbers" in the third argument. So if you wanted to only[/color][/color]
              use the[color=blue][color=green]
              > > first, third and fifth fields in the recordset, you could do this:
              > >
              > > arResults = rs.GetRows(,,ar ray(0,2,4))[/color][/color]

              No, there is no parameter for the GetString method that corresponds to
              the Fields parameter in the GetRows method. However, I'll bet
              dollars-to-donuts that if you provide the sql statement we can "hide"
              the fields you don't need.

              HTH
              -Chris Hohmann


              Comment

              • Crane Linkledder

                #8
                Re: Difference between getrows and getstring

                It says-
                Variant = recordset.GetSt ring(StringForm at, NumRows, ColumnDelimiter ,
                RowDelimiter, NullExpr)
                It does not look like it is possible to filter out columns using getString.
                How can I get around this?TIA

                "Bob Barrows" <reb01501@NOyah oo.SPAMcom> wrote in message
                news:uFz$tfnnDH A.2216@TK2MSFTN GP12.phx.gbl...[color=blue]
                > Crane Linkledder wrote:[color=green]
                > > Thanks to the both of you. One last question. When using getrows, is
                > > it possible to exclude specific columns?
                > >[/color]
                > The documentation is here:
                > http://msdn.microsoft.com/library/en...damth02_10.asp
                >
                > As you will see, you can supply an " ... array of field names or ordinal
                > position numbers" in the third argument. So if you wanted to only use the
                > first, third and fifth fields in the recordset, you could do this:
                >
                > arResults = rs.GetRows(,,ar ray(0,2,4))
                >
                > The MSDN Library is your friend.
                >
                > HTH,
                > Bob Barrows
                >
                > --
                > Microsoft MVP -- ASP/ASP.NET
                > Please reply to the newsgroup. The email account listed in my From
                > header is my spam trap, so I don't check it very often. You will get a
                > quicker response by posting to the newsgroup.
                >
                >[/color]


                Comment

                • Crane Linkledder

                  #9
                  Re: Difference between getrows and getstring

                  Thank you. I was starting to panic.


                  Here is my statement-

                  SQL = "SELECT " & users & ".one, " & users & ".two,
                  "&calendar&".ap pointmentStart, "&calendar&".ap pointmentEnd, "&calendar&".ID ,
                  "&calendar&".ow nerID, "&calendar&".cl ientID, " & users & ".userID " &_
                  "FROM "&calendar& ", " & users & " " &_
                  "WHERE "&users&".userI D = "&calendar&".cl ientID " &_
                  " AND recurring = '0' ORDER BY appointmentStar t"


                  I am trying to avoid displaying-

                  calendar&".owne rID "
                  calendar&".clie ntID "
                  users & ".userID "











                  "Chris Hohmann" <nospam@thankyo u.com> wrote in message
                  news:%23B1w1znn DHA.3304@tk2msf tngp13.phx.gbl. ..[color=blue]
                  > "Crane Linkledder" <Linkledder@NOT ADOMAIN.com> wrote in message
                  > news:%231bvGlnn DHA.1296@TK2MSF TNGP09.phx.gbl. ..[color=green]
                  > > I'm sorry. I meant getString. Is this true with getString also?
                  > >
                  > >
                  > > "Bob Barrows" <reb01501@NOyah oo.SPAMcom> wrote in message
                  > > news:uFz$tfnnDH A.2216@TK2MSFTN GP12.phx.gbl...[color=darkred]
                  > > > Crane Linkledder wrote:
                  > > > > Thanks to the both of you. One last question. When using getrows,[/color][/color]
                  > is[color=green][color=darkred]
                  > > > > it possible to exclude specific columns?
                  > > > >
                  > > > The documentation is here:
                  > > > http://msdn.microsoft.com/library/en...damth02_10.asp
                  > > >
                  > > > As you will see, you can supply an " ... array of field names or[/color][/color]
                  > ordinal[color=green][color=darkred]
                  > > > position numbers" in the third argument. So if you wanted to only[/color][/color]
                  > use the[color=green][color=darkred]
                  > > > first, third and fifth fields in the recordset, you could do this:
                  > > >
                  > > > arResults = rs.GetRows(,,ar ray(0,2,4))[/color][/color]
                  >
                  > No, there is no parameter for the GetString method that corresponds to
                  > the Fields parameter in the GetRows method. However, I'll bet
                  > dollars-to-donuts that if you provide the sql statement we can "hide"
                  > the fields you don't need.
                  >
                  > HTH
                  > -Chris Hohmann
                  >
                  >[/color]


                  Comment

                  • Bob Barrows

                    #10
                    Re: Difference between getrows and getstring

                    Crane Linkledder wrote:[color=blue]
                    > Thank you. I was starting to panic.
                    >
                    >
                    > Here is my statement-
                    >
                    > SQL = "SELECT " & users & ".one, " & users & ".two,
                    > "&calendar&".ap pointmentStart, "&calendar&".ap pointmentEnd,
                    > "&calendar&".ID , "&calendar&".ow nerID, "&calendar&".cl ientID, " &
                    > users & ".userID " &_ "FROM "&calendar& ", " & users & " " &_
                    > "WHERE "&users&".userI D = "&calendar&".cl ientID " &_
                    > " AND recurring = '0' ORDER BY appointmentStar t"
                    >
                    >
                    > I am trying to avoid displaying-
                    >
                    > calendar&".owne rID "
                    > calendar&".clie ntID "
                    > users & ".userID "
                    >[/color]
                    Why retrieve the fields at all if you don't want to display them?

                    Are you doing something else with their contents behind the scenes? If so,
                    you will need to go with the GetRows solution.

                    Bob Barrows


                    --
                    Microsoft MVP - ASP/ASP.NET
                    Please reply to the newsgroup. This email account is my spam trap so I
                    don't check it very often. If you must reply off-line, then remove the
                    "NO SPAM"


                    Comment

                    • Crane Linkledder

                      #11
                      Re: Difference between getrows and getstring


                      "Bob Barrows" <reb01501@NOyah oo.SPAMcom> wrote in message
                      news:u4HLsDonDH A.2676@TK2MSFTN GP11.phx.gbl...[color=blue]
                      > Crane Linkledder wrote:[color=green]
                      > > Thank you. I was starting to panic.
                      > >
                      > >
                      > > Here is my statement-
                      > >
                      > > SQL = "SELECT " & users & ".one, " & users & ".two,
                      > > "&calendar&".ap pointmentStart, "&calendar&".ap pointmentEnd,
                      > > "&calendar&".ID , "&calendar&".ow nerID, "&calendar&".cl ientID, " &
                      > > users & ".userID " &_ "FROM "&calendar& ", " & users & " " &_
                      > > "WHERE "&users&".userI D = "&calendar&".cl ientID " &_
                      > > " AND recurring = '0' ORDER BY appointmentStar t"
                      > >
                      > >
                      > > I am trying to avoid displaying-
                      > >
                      > > calendar&".owne rID "
                      > > calendar&".clie ntID "
                      > > users & ".userID "
                      > >[/color]
                      > Why retrieve the fields at all if you don't want to display them?
                      >
                      > Are you doing something else with their contents behind the scenes? If so,
                      > you will need to go with the GetRows solution.
                      >
                      > Bob Barrows
                      >
                      >
                      > --
                      > Microsoft MVP - ASP/ASP.NET
                      > Please reply to the newsgroup. This email account is my spam trap so I
                      > don't check it very often. If you must reply off-line, then remove the
                      > "NO SPAM"
                      >
                      >[/color]


                      I somehow got it in my head that I needed to select all the columns that I'm
                      using in my select statement... WHERE column6 = column7

                      I just removed those and it's working regardless.

                      Thanks for pointing that out.











                      Comment

                      • Aaron Bertrand - MVP

                        #12
                        Re: Difference between getrows and getstring

                        > I am selecting more columns in my SELECT statement than I'd like to
                        display[color=blue]
                        > on screen. How can I filter them out?[/color]

                        Drop them from the SELECT? Why are you bothering to select them if you're
                        not using them?


                        Comment

                        Working...