473,387 Members | 3,801 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,387 software developers and data experts.

Equivalent for RecordCount

In VB6, I could count the number of records in a recordset
using recordcount.

Is there an equivalent in VB.NET, to be able to count the
rows in a Data Set?

Thanks in Advance,
Elena
Nov 20 '05 #1
10 2605
Cor
dataset.tables(x).rows.count

"> In VB6, I could count the number of records in a recordset
using recordcount.

Is there an equivalent in VB.NET, to be able to count the
rows in a Data Set?

Nov 20 '05 #2
DataSet's can contain multiple tables, so there is not inhernet count
property b/c it wouldn't know which one you wanted a count for.

However, for a DataTable, you can use MyDataSet.Tables("DataTableName Or
Index").Rows.Count

If you are only doing it once, don't worry about using the table name, but
in general use an index to reference it. Or as the ADO.NET guru Bill
Vaughn suggests, you can an enumeration so you get the clarity of a real
name with the performance of an index.
"ElenaR" <el**********@yahoo.com> wrote in message
news:0c****************************@phx.gbl...
In VB6, I could count the number of records in a recordset
using recordcount.

Is there an equivalent in VB.NET, to be able to count the
rows in a Data Set?

Thanks in Advance,
Elena

Nov 20 '05 #3
Thanks Cor,

You're always such a help.

Elena
-----Original Message-----
dataset.tables(x).rows.count

"> In VB6, I could count the number of records in a

recordset
using recordcount.

Is there an equivalent in VB.NET, to be able to count the rows in a Data Set?

.

Nov 20 '05 #4
With this code (dataset.tables(x).rows.count), I get a
task error:
Property access must assign to the property or use its
value.

I pasted the code below to be a reference.

Elena

strsql = "Select * from Action where item_identifier = " &
Val(TextBox5.Text) & " order by action_identifier"
' Create data adapter object
Dim daID As OleDbDataAdapter = New OleDbDataAdapter
(strsql, CriticalParts.conn)
' Create a dataset object and fill with data using data
adapter's Fill method
Dim dsID As DataSet = New DataSet
daID.Fill(dsID, "Action")

dsID.Tables(1).Rows.Count()
-----Original Message-----
dataset.tables(x).rows.count

"> In VB6, I could count the number of records in a

recordset
using recordcount.

Is there an equivalent in VB.NET, to be able to count the rows in a Data Set?

.

Nov 20 '05 #5
Cor
ElenaR,

All Net indexes starts at 0, Microsoft VisualBasic indexes at 1
dsID.Tables(1).Rows.Count


And you have 1 table so

dsID.tables(0).Rows.Count

Cor
Nov 20 '05 #6
On Fri, 7 Nov 2003 09:17:29 -0800, ElenaR wrote:
With this code (dataset.tables(x).rows.count), I get a
task error:
Property access must assign to the property or use its
value.
dsID.Tables(1).Rows.Count()


Count is a property and not a method. You need to assign the count to some
variable or something:

lngRecordCount = dsID.Tables(1).Rows.Count

--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.
Nov 20 '05 #7
Cor,

With an index of 0, I still get the same error:
Property access must assign to the property or use its
value.
-----Original Message-----
ElenaR,

All Net indexes starts at 0, Microsoft VisualBasic indexes at 1
dsID.Tables(1).Rows.Count


And you have 1 table so

dsID.tables(0).Rows.Count

Cor
.

Nov 20 '05 #8
Cor
And of course what Chris said, this would be the next error.
:-))

All Net indexes starts at 0, Microsoft VisualBasic indexes at 1
dsID.Tables(1).Rows.Count

And you have 1 table so
dsID.tables(0).Rows.Count

Nov 20 '05 #9
Cor
Hi Elenora

dim a as integer = dsID.Tables(0).Rows.Count

I am in a hurry have to go to a funeral in some minutes.
(Not nearby persons)

Cor
Nov 20 '05 #10
perfect!

Elena
-----Original Message-----
On Fri, 7 Nov 2003 09:17:29 -0800, ElenaR wrote:
With this code (dataset.tables(x).rows.count), I get a
task error:
Property access must assign to the property or use its
value.
dsID.Tables(1).Rows.Count()

Count is a property and not a method. You need to assign

the count to somevariable or something:

lngRecordCount = dsID.Tables(1).Rows.Count

--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mailaddress.
.

Nov 20 '05 #11

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

Similar topics

6
by: Mark Watkins | last post by:
I know for a fact that in my database, I have three records under the users table. However when I execute this code: --------------BEGIN CODE---------------- Set objConn =...
2
by: Jeff Boyer | last post by:
Hello everyone, Can someone tell me why a ADO recordset.recordcount would return a -1? I have confirmed that it has records in it by writing some values to the screen. Why can't I count the...
12
by: scott | last post by:
In LISTING 2, I have a SPROC that returns a recordset and a recordcount in SQL QA. I can access the Recordset with no problem. How can I grab the Recordcount with ASP code at the same time I'm...
4
by: don.fleming | last post by:
Hi folks: Am doing a VBA SQL Select stmt with multiple rows found and not getting RecordCount > 1. I've verified there are multiple rows found by copying my SQL stmt from Debug window and pasting...
2
by: Andrew Poulos | last post by:
A friend of mine has built as simple site for use on his company's intranet. It uses JavaScript to read comma-delimited information from a text file and displays it in tabular form. When I...
10
by: Robert | last post by:
How do you get an accurate count of the number of records returned from a query when using linked tables. I have an access 2003 database as a front end to another access 2003 database that...
2
by: rajvbprogramer | last post by:
here is my problem. i have two records. one containing 20 records and second containing 30 records. now i want the recordcount property to use and go to the 21 record. i m calculating the...
1
by: qqmbers | last post by:
May be it will help someone. I faced the strange problem with RecordCount property of cloned Recordset within the Current event handler. The RecordCount value was correct every time I had...
3
by: sparks | last post by:
Is recordcount a little messed or what? For Each tdf In dbs.TableDefs If Left(tdf.Name, 3) = "tbl" Then Debug.Print tdf.Name Debug.Print tdf.RecordCount it prints the correct name but the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...

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.