473,322 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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 @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
Nov 17 '05 #1
3 8985
Try

MyDataset.Tables(0).Rows.Count

Chris Wilmot
"John Pether" <john@<nospam>dotnetsites.net> wrote in message
news:OR**************@TK2MSFTNGP12.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 @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP &

ASP.NET resources...
Nov 17 '05 #2
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:OR**************@TK2MSFTNGP12.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 @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP &

ASP.NET resources...
Nov 17 '05 #3
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 @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ireneus Broncel | last post by:
I have a class which reads Groups and Users from ActiveDirectory. The Problem is, that i have about 10000 rows as product. When I am trying to read the "memberOf" Objects out of this field i get...
2
by: Alpha | last post by:
I have a window application. In one of the form, a datagrid has a dataview as its datasource. Initial filtering result would give the datavew 3 items. When I double click on the datagrid to edit...
3
by: John Pether (john | last post by:
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() '...
6
by: Kulwinder Sayal | last post by:
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
6
by: Tejpal Garhwal | last post by:
I have datagrid filled with some data rows. At the run time i want know how many total rows are there in the data grid ? Any idea ? Any Suggestions ? Thanks in advance Tej
3
by: Hyphessobricon | last post by:
Hallo, Indeed, a count of a query with a group by function gives more records than there are and so for-next structures don't function. How is this to be mended. Anyone? Everyone in fact....
3
by: Sam | last post by:
Hi, I've got a datagrid and a dataset used as the datasource. I'd like to do a test, if the index of the selected row in the grid is greater than the dataset.tables(0).rows.count. The problem is...
5
by: simon | last post by:
Hello is there a variable that is available to me that contains the number of rows contained in a dataset return from a database call? have a class that runs a stored proc and returns a...
4
by: Peter W Johnson | last post by:
Hi guys, I have a problem with a datagrid record count. Here is the code:- <snip> Public Class frmMerchantDeposit Inherits System.Windows.Forms.Form Dim myconnection As New...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.