473,324 Members | 2,548 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,324 software developers and data experts.

Variable that holds the record count of a result set?

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!

Jan 18 '06 #1
5 4377
Hi Simon,

a dataset after it's filled contains one or more tables which you can
address like this: DataSet.Tables(0)
mostlike the tables contains rows which you can address like this
DataSet.Tables(0).Rows(index) and then again the rows have got a count
property, what you need. So if you want the know the number of rows
contained in a dataset table you can use
DataSet.Tables(tableIndex).Rows.Count()
Hope this helps

Greetz Peter
--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)
"simon" <me@here.com> schreef in bericht
news:60********************************@4ax.com...
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!

Jan 18 '06 #2
"simon" <me@here.com> wrote in message
news:60********************************@4ax.com...
is there a variable that is available to me that contains the number
of rows contained in a dataset return from a database call?


Not for the DataSet itself, but on [each of] the DataTable(s) that it
contains, as in

Dim ds as DataSet = GoGetDataAsDataSet()

? ds.Tables( 0 ).Rows

HTH,
Phill W.
Jan 18 '06 #3
thanks guys. i'll try it out tonight
appreciate the replies!

Jan 18 '06 #4
If you are using a dataadapter to populate your dataset, the return
value is the number of rows affected:

Dim r as integer = MyDataAdapter.Fill(MyDataSet)
Debug.Write r.ToString & " rows returned"

OR

If you just want to know howmany rows there will be, change your stored
procedure (have an alternative proc) to do a count rather than return
records

In message <60********************************@4ax.com>, simon
<me@here.com> writes
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!


--
Chris Petchey
Jan 18 '06 #5
thanks chris. i think this is exactly what i'm looking for.
is it possible to get this count before or after the fill takes place
or can does it need to occur while doing the fill?
examples are always apprecaited by newbies :-D
On Wed, 18 Jan 2006 14:47:30 +0000, Chris Petchey
<ch****@soltec.demon.co.uk> wrote:
Dim r as integer = MyDataAdapter.Fill(MyDataSet)
Debug.Write r.ToString & " rows returned"


Jan 18 '06 #6

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

Similar topics

1
by: ak | last post by:
Hello, I have following problem: I try to retrieve images from mysql and show it. I retrieve them in loop using getData.php. getData.php uses session variable ($_SESSION) to get image. ...
23
by: stewart.midwinter | last post by:
No doubt I've overlooked something obvious, but here goes: Let's say I assign a value to a var, e.g.: myPlace = 'right here' myTime = 'right now' Now let's say I want to print out the two...
4
by: Greg | last post by:
I need to send the result of a procedure to an update statement. Basically updating the column of one table with the result of a query in a stored procedure. It only returns one value, if it didnt...
6
by: romerun | last post by:
Hello, This make me very confusing: ---------------------------------- int &kkk() { int a = 5; return a; }
6
by: deko | last post by:
Set strFoundCt = ("SELECT COUNT(*) FROM (SELECT DISTINCT Entity_ID FROM qrySearch" & strPxSx) This doesn't work, but hopefully describes what I'm trying to do. I have several different queries...
8
by: Groups User | last post by:
C allows type casting in which a variable is converted from one type to another. Does C (whatever standard) allow the type of a variable to change, within a statement, avoiding the conversion?...
9
by: Shapper | last post by:
Hello, I am declaring a variable in my aspx.vb code as follows: Public Class catalogue Public productid As String Private Sub Page_Load ... I have an image button where I call the...
61
by: Marty | last post by:
I am new to C# and to structs so this could be easy or just not possible. I have a struct defined called Branch If I use Branch myBranch = new Branch(i); // everything works If I use Branch...
6
by: rJ | last post by:
hi, what does the following statement mean and what does it do? Dim obTest As Record.Class1 = CType(Class2.GetSessionInfo(class3.TestConstant), Record.Class1) GetSessionInfo() simply does...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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.