473,847 Members | 1,499 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.LinksInd exDB()

' DataBind Links to DataGrid Control

DG.DataSource = links.GetLinks( CatID)
DG.DataBind()
DLLegend.DataSo urce = links.GetGroups
DLLegend.DataBi nd()
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 9023
Try

MyDataset.Table s(0).Rows.Count

Chris Wilmot
"John Pether" <john@<nospam>d otnetsites.net> wrote in message
news:OR******** ******@TK2MSFTN GP12.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.LinksInd exDB()

' DataBind Links to DataGrid Control

DG.DataSource = links.GetLinks( CatID)
DG.DataBind()
DLLegend.DataSo urce = links.GetGroups
DLLegend.DataBi nd()
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>d otnetsites.net> wrote in message
news:OR******** ******@TK2MSFTN GP12.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.LinksInd exDB()

' DataBind Links to DataGrid Control

DG.DataSource = links.GetLinks( CatID)
DG.DataBind()
DLLegend.DataSo urce = links.GetGroups
DLLegend.DataBi nd()
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(s trConnection)
' Create Instance of Connection and Command Object
Dim myCommand As New SqlCommand("Get Links", myConnection)

' Mark the Command as a SPROC
myCommand.Comma ndType = CommandType.Sto redProcedure

' Add Parameters to SPROC

Dim parameterCatID As New SqlParameter("@ CatID", SqlDbType.BigIn t)
parameterCatID. Value = CatID
myCommand.Param eters.Add(param eterCatID)

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

' Execute the command
myConnection.Op en()
myCommand.Execu teNonQuery()
myConnection.Cl ose()

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
4682
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 allways different count of rows. If anybody knows something about this kind of problem, I would appreciate any help. Thx.
2
3317
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 the selected lie item at which case I would pop up a separate dialog box to do so, in the debugging code, the dataview.count would return 0. I get a error message because I tried to get values out of a dataview that holds 0 items. Does anyone...
3
2624
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() ' DataBind Links to DataGrid Control DG.DataSource = links.GetLinks(CatID)
6
320
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
6710
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
1669
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. Answers are greatly appreciated. -- mvg Hyphessobrycon
3
10340
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 that if I edit the last row of the grid, a new row will be added below and to the dataset. Therefore the number of rows in the dataset won't be equal to the number of records in the database. How can I get the number of rows in the dataset...
5
4395
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 dataset/resultset looking to simply assign an integer this value if it is possible i'm using (learning) vb.net thanks again for any help!
4
3094
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 Odbc.OdbcConnection("DSN=database")
0
9892
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
10991
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10653
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10718
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10347
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7061
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5725
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5915
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4540
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.