Professional Web Applications Themes

count rows in dataset... - ASP.NET General

Try MyDataset.Tables(0).Rows.Count Chris Wilmot "John Pether" <john<nospam>dotnetsites.net> wrote in message news:ORC$H6cUDHA.2284TK2MSFTNGP12.phx.gbl... > I have the following code which loads a dataset into a datagrid: > <code> > ' Obtain Link information from Links table > ' and bind to the datagrid control > > Dim links As New DNSite.LinksIndexDB() > > ' DataBind Links to DataGrid Control > > DG.DataSource = links.GetLinks(CatID) > DG.DataBind() > DLLegend.DataSource = links.GetGroups > DLLegend.DataBind() > TotalLinks = > </code> > > TotalLinks needs to be the number of rows of data from the dataset links.GetLinks > > Can anyone tell me how I access ...

  1. #1

    Default Re: count rows in dataset...

    Try

    MyDataset.Tables(0).Rows.Count

    Chris Wilmot
    "John Pether" <john<nospam>dotnetsites.net> wrote in message
    news:ORC$H6cUDHA.2284TK2MSFTNGP12.phx.gbl...
    > I have the following code which loads a dataset into a datagrid:
    > <code>
    > ' Obtain Link information from Links table
    > ' and bind to the datagrid control
    >
    > Dim links As New DNSite.LinksIndexDB()
    >
    > ' DataBind Links to DataGrid Control
    >
    > DG.DataSource = links.GetLinks(CatID)
    > DG.DataBind()
    > DLLegend.DataSource = links.GetGroups
    > DLLegend.DataBind()
    > TotalLinks =
    > </code>
    >
    > TotalLinks needs to be the number of rows of data from the dataset
    links.GetLinks
    >
    > Can anyone tell me how I access that info?
    >
    > thx:)
    >
    >
    > ************************************************** ********************
    > Sent via Fuzzy Software [url]http://www.fuzzysoftware.com/[/url]
    > Comprehensive, categorised, searchable collection of links to ASP &
    ASP.NET resources...


    Chris Wilmot Guest

  2. #2

    Default count rows in dataset...

    I have the following code which loads a dataset into a datagrid:
    <code>
    ' Obtain Link information from Links table
    ' and bind to the datagrid control

    Dim links As New DNSite.LinksIndexDB()

    ' DataBind Links to DataGrid Control

    DG.DataSource = links.GetLinks(CatID)
    DG.DataBind()
    DLLegend.DataSource = links.GetGroups
    DLLegend.DataBind()
    TotalLinks =
    </code>

    TotalLinks needs to be the number of rows of data from the dataset links.GetLinks

    Can anyone tell me how I access that info?

    thx:)


    ************************************************** ********************
    Sent via Fuzzy Software [url]http://www.fuzzysoftware.com/[/url]
    Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
    John Pether (john@ Guest

  3. #3

    Default Re: count rows in dataset...

    Before binding your datasource with datagrid, load it in local dataset and
    then find out the count. For example,

    Dataset1 = links.GetLinks(CatID)
    Dataset1.tables(0).rows.count
    DG.DataSource= DataSet1



    --
    Saravana
    Microsoft India Community Star,
    MCAD,SE,SD,DBA.


    "John Pether" <john<nospam>dotnetsites.net> wrote in message
    news:ORC$H6cUDHA.2284TK2MSFTNGP12.phx.gbl...
    > I have the following code which loads a dataset into a datagrid:
    > <code>
    > ' Obtain Link information from Links table
    > ' and bind to the datagrid control
    >
    > Dim links As New DNSite.LinksIndexDB()
    >
    > ' DataBind Links to DataGrid Control
    >
    > DG.DataSource = links.GetLinks(CatID)
    > DG.DataBind()
    > DLLegend.DataSource = links.GetGroups
    > DLLegend.DataBind()
    > TotalLinks =
    > </code>
    >
    > TotalLinks needs to be the number of rows of data from the dataset
    links.GetLinks
    >
    > Can anyone tell me how I access that info?
    >
    > thx:)
    >
    >
    > ************************************************** ********************
    > Sent via Fuzzy Software [url]http://www.fuzzysoftware.com/[/url]
    > Comprehensive, categorised, searchable collection of links to ASP &
    ASP.NET resources...


    Saravana Guest

  4. #4

    Default Re: count rows in dataset...

    ok, so i wasn't able to do that in the code behind but I can do it in the function from the data access class file, see code below
    So I have created a Dim TotalLinks and filled it but how do I access that from my page behind code??? any ideas?

    <code>
    Public Function GetLinks(ByVal CatID As Long) As DataSet
    Dim myConnection As New SqlConnection(strConnection)
    ' Create Instance of Connection and Command Object
    Dim myCommand As New SqlCommand("GetLinks", myConnection)

    ' Mark the Command as a SPROC
    myCommand.CommandType = CommandType.StoredProcedure

    ' Add Parameters to SPROC

    Dim parameterCatID As New SqlParameter("CatID", SqlDbType.BigInt)
    parameterCatID.Value = CatID
    myCommand.Parameters.Add(parameterCatID)

    '********ADDED*********
    Dim TotalLinks As Long
    TotalLinks = GetLinks.Tables(0).Rows.Count
    '********ADDED*********

    ' Execute the command
    myConnection.Open()
    myCommand.ExecuteNonQuery()
    myConnection.Close()

    End Function

    ************************************************** ********************
    Sent via Fuzzy Software [url]http://www.fuzzysoftware.com/[/url]
    Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
    John Pether (john@ Guest

Similar Threads

  1. rows count
    By Aaron Bertrand - MVP in forum ASP Database
    Replies: 2
    Last Post: April 8th, 11:22 AM
  2. Count excel Rows
    By s6868 in forum Macromedia ColdFusion
    Replies: 3
    Last Post: March 26th, 12:47 AM
  3. Replies: 3
    Last Post: May 11th, 07:43 PM
  4. Replies: 0
    Last Post: December 29th, 07:47 PM
  5. [PHP] count rows
    By John Taylor-Johnston in forum PHP Development
    Replies: 1
    Last Post: August 22nd, 08:00 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139