Variable that holds the record count of a result set?

  • Thread starter Thread starter simon
  • Start date Start date
S

simon

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!
 
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
 
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.
 
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top