Record Count

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kulwinder Sayal

    Record Count

    Hi

    In ASP it was so simple to get the no. of records using RecordCount. Can anyone help me how to write the no. of records my sqlquery has searched

    Thanks
    Kulwinder
  • Ashish Sharma

    #2
    Re: Record Count

    Kulwinder Sayal wrote:[color=blue]
    > Hi,
    >
    > In ASP it was so simple to get the no. of records using RecordCount. Can anyone help me how to write the no. of records my sqlquery has searched?
    >
    > Thanks,
    > Kulwinder[/color]

    DataSet.Tables( 0).Rows.Count

    Comment

    • Ashish Sharma

      #3
      Re: Record Count

      Kulwinder Sayal wrote:[color=blue]
      > Hi,
      >
      > In ASP it was so simple to get the no. of records using RecordCount. Can anyone help me how to write the no. of records my sqlquery has searched?
      >
      > Thanks,
      > Kulwinder[/color]

      DataSet.Tables( 0).Rows.Count

      Comment

      • zveda

        #4
        Re: Record Count

        What DB are you using? If SQL Server, are you using stored procedures or
        dynamic SQL? Are you using ADO.NET? Help us help you: tell us more about
        what you are trying to accomplish.



        "Kulwinder Sayal" <anonymous@disc ussions.microso ft.com> wrote in message
        news:97535BEA-C387-4F0C-ABEA-316A7435D764@mi crosoft.com...[color=blue]
        > Hi,
        >
        > In ASP it was so simple to get the no. of records using RecordCount. Can[/color]
        anyone help me how to write the no. of records my sqlquery has searched?[color=blue]
        >
        > Thanks,
        > Kulwinder[/color]


        Comment

        • zveda

          #5
          Re: Record Count

          What DB are you using? If SQL Server, are you using stored procedures or
          dynamic SQL? Are you using ADO.NET? Help us help you: tell us more about
          what you are trying to accomplish.



          "Kulwinder Sayal" <anonymous@disc ussions.microso ft.com> wrote in message
          news:97535BEA-C387-4F0C-ABEA-316A7435D764@mi crosoft.com...[color=blue]
          > Hi,
          >
          > In ASP it was so simple to get the no. of records using RecordCount. Can[/color]
          anyone help me how to write the no. of records my sqlquery has searched?[color=blue]
          >
          > Thanks,
          > Kulwinder[/color]


          Comment

          • Kevin Spencer

            #6
            Re: Record Count

            Actually, ASP has no methods for connecting with a database. You're
            referring to ADO (ActiveX Data Objects). There are more than one set of
            classes for working with databases in the .Net platform. Most likely, you
            are tlaking about either a DataReader, DataSet or a DataTable. A DataReader
            is a forward-only, read-only cursor, from which you can not get a count of
            records until it is closed. The best way with a DataReader is to count as
            you loop through the records. A DataSet is not a container for database
            results per se, but a container for DataTables. A DataTable is a complete
            RecordSet fetched from a data source. It has a Rows Collection of all the
            rows of data in the Result Set. You can get a count by checking the Count
            property of the Rows Collection. Example:

            int intCt = MyDataTable.Row s.Count;

            --
            HTH,
            Kevin Spencer
            ..Net Developer
            Microsoft MVP
            Big things are made up
            of lots of little things.

            "Kulwinder Sayal" <anonymous@disc ussions.microso ft.com> wrote in message
            news:97535BEA-C387-4F0C-ABEA-316A7435D764@mi crosoft.com...[color=blue]
            > Hi,
            >
            > In ASP it was so simple to get the no. of records using RecordCount. Can[/color]
            anyone help me how to write the no. of records my sqlquery has searched?[color=blue]
            >
            > Thanks,
            > Kulwinder[/color]


            Comment

            • Kevin Spencer

              #7
              Re: Record Count

              Actually, ASP has no methods for connecting with a database. You're
              referring to ADO (ActiveX Data Objects). There are more than one set of
              classes for working with databases in the .Net platform. Most likely, you
              are tlaking about either a DataReader, DataSet or a DataTable. A DataReader
              is a forward-only, read-only cursor, from which you can not get a count of
              records until it is closed. The best way with a DataReader is to count as
              you loop through the records. A DataSet is not a container for database
              results per se, but a container for DataTables. A DataTable is a complete
              RecordSet fetched from a data source. It has a Rows Collection of all the
              rows of data in the Result Set. You can get a count by checking the Count
              property of the Rows Collection. Example:

              int intCt = MyDataTable.Row s.Count;

              --
              HTH,
              Kevin Spencer
              ..Net Developer
              Microsoft MVP
              Big things are made up
              of lots of little things.

              "Kulwinder Sayal" <anonymous@disc ussions.microso ft.com> wrote in message
              news:97535BEA-C387-4F0C-ABEA-316A7435D764@mi crosoft.com...[color=blue]
              > Hi,
              >
              > In ASP it was so simple to get the no. of records using RecordCount. Can[/color]
              anyone help me how to write the no. of records my sqlquery has searched?[color=blue]
              >
              > Thanks,
              > Kulwinder[/color]


              Comment

              • Kulwinder Sayal

                #8
                Re: Record Count

                Hi

                I'm using SQL Server and Data Reader to get the record. IF I can't do the record count while i'm using data reader, how can i count the no. of search results??

                Please help... Give me a nice example

                TIA
                Kulwinde


                Comment

                • Kulwinder Sayal

                  #9
                  Re: Record Count

                  Hi

                  I'm using SQL Server and Data Reader to get the record. IF I can't do the record count while i'm using data reader, how can i count the no. of search results??

                  Please help... Give me a nice example

                  TIA
                  Kulwinde


                  Comment

                  • Kevin Spencer

                    #10
                    Re: Record Count

                    You might want to re-read my message. I told you how to do it in the
                    message:

                    " The best way with a DataReader is to count as you loop through the
                    records. "

                    --
                    HTH,
                    Kevin Spencer
                    ..Net Developer
                    Microsoft MVP
                    Big things are made up
                    of lots of little things.

                    "Kulwinder Sayal" <anonymous@disc ussions.microso ft.com> wrote in message
                    news:5403839C-55A3-40B3-B2C8-643C775E9AF0@mi crosoft.com...[color=blue]
                    > Hi,
                    >
                    > I'm using SQL Server and Data Reader to get the record. IF I can't do the[/color]
                    record count while i'm using data reader, how can i count the no. of search
                    results???[color=blue]
                    >
                    > Please help... Give me a nice example.
                    >
                    > TIA,
                    > Kulwinder
                    >
                    >[/color]


                    Comment

                    • Kevin Spencer

                      #11
                      Re: Record Count

                      You might want to re-read my message. I told you how to do it in the
                      message:

                      " The best way with a DataReader is to count as you loop through the
                      records. "

                      --
                      HTH,
                      Kevin Spencer
                      ..Net Developer
                      Microsoft MVP
                      Big things are made up
                      of lots of little things.

                      "Kulwinder Sayal" <anonymous@disc ussions.microso ft.com> wrote in message
                      news:5403839C-55A3-40B3-B2C8-643C775E9AF0@mi crosoft.com...[color=blue]
                      > Hi,
                      >
                      > I'm using SQL Server and Data Reader to get the record. IF I can't do the[/color]
                      record count while i'm using data reader, how can i count the no. of search
                      results???[color=blue]
                      >
                      > Please help... Give me a nice example.
                      >
                      > TIA,
                      > Kulwinder
                      >
                      >[/color]


                      Comment

                      • Kevin Spencer

                        #12
                        Re: Record Count

                        The following page on the MSDN Library contains an example:



                        --
                        HTH,
                        Kevin Spencer
                        ..Net Developer
                        Microsoft MVP
                        Big things are made up
                        of lots of little things.

                        "Kulwinder Sayal" <anonymous@disc ussions.microso ft.com> wrote in message
                        news:5403839C-55A3-40B3-B2C8-643C775E9AF0@mi crosoft.com...[color=blue]
                        > Hi,
                        >
                        > I'm using SQL Server and Data Reader to get the record. IF I can't do the[/color]
                        record count while i'm using data reader, how can i count the no. of search
                        results???[color=blue]
                        >
                        > Please help... Give me a nice example.
                        >
                        > TIA,
                        > Kulwinder
                        >
                        >[/color]


                        Comment

                        • Kevin Spencer

                          #13
                          Re: Record Count

                          The following page on the MSDN Library contains an example:



                          --
                          HTH,
                          Kevin Spencer
                          ..Net Developer
                          Microsoft MVP
                          Big things are made up
                          of lots of little things.

                          "Kulwinder Sayal" <anonymous@disc ussions.microso ft.com> wrote in message
                          news:5403839C-55A3-40B3-B2C8-643C775E9AF0@mi crosoft.com...[color=blue]
                          > Hi,
                          >
                          > I'm using SQL Server and Data Reader to get the record. IF I can't do the[/color]
                          record count while i'm using data reader, how can i count the no. of search
                          results???[color=blue]
                          >
                          > Please help... Give me a nice example.
                          >
                          > TIA,
                          > Kulwinder
                          >
                          >[/color]


                          Comment

                          Working...