Results 1 to 9 of 9

Thread: How to find the number of rows read into a data source

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2004
    Posts
    20

    How to find the number of rows read into a data source

    Hey,
    I have an access database (soon to be SQL) that I have read over 3000 rows into a data source. I have to use the number of rows to do some of the programming. How do I find out the number of rows as it will be different with many different files that this will use.

    I am using VB.net

    Thanks,
    Nicholas

  2. #2
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    have an access database (soon to be SQL) that I have read over 3000 rows into a data source. I have to use the number of rows to do some of the programming. How do I find out the number of rows as it will be different with many different files that this will use.

    You mean you have read them into a dataset? In that case, you would simply call the appropriate table's rows.count property.

    I'm also curious as to how the number of rows affects your programming...

    Post your code...

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jul 2004
    Posts
    20
    Hey,
    Thanks for your help. Is there some please where I can find all of the properties such as "rows.count".

    Would you mind giving me a short example even if it is just the row of what "rows.count" goes with.


    I cannot give you my code though due to it being work related. But I am running a program that gets data that is put into once a week and I have to do some checking and comparing with it so I have to go through each row and need the number of rows for the "for loop". So I can hit the end of the file and stop at that. Since the number of rows change every week it will continue to go after the last row if I do not put a limit in there and I cannot change it every week.


    Thanks so much!!!!

    Nicholas

  4. #4
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    VB Code:
    1. Dim count As Integer = 0
    2. while dr.read
    3.   count +=1
    4.   '...
    5. end while

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jul 2004
    Posts
    20
    I use the "OleDbDataAdapter1.Fill" and it fills the data for me. How do I do that when it automaticly fills the data for me??

  6. #6
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    What's the name of the dataset you are filling?

    How many tables does it have?

    What table is the table you want to know how many rows it has?

    VB Code:
    1. dataAdaptor1.Fill(ds)
    2. Dim rowscount As Integer = ds.Tables(0).Rows.Count

    Btw, in Visual Studio, simply highlight a line of code with DataTable in it, and press F1....(or click Help.. Index... Type 'DataTable', hit ENTER, click on DataTable Class) it will bring up a complete summary of the DataTable class.

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Jul 2004
    Posts
    20
    HEY THANKS!!!!!!

    That worked GREAT!!!!!

    Were do you find out those type of things "Dim rowscount As Integer = ds.Tables(0).Rows.Count"

    I have needed several types of these and is there a book that has them or any website that has them???

    Also I only have one table does the "0" in the perenteses make a different??? I left it as zero. If I had more than 1 table would it be different??


    THANKS SO MUCH!!
    Nicholas

  8. #8
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    HELP:
    MSDN LIBRARY

    http://msdn.microsoft.com/library/de...ClassTopic.asp

    BOOKS:
    There really is one book you absolutely need... it only has 3 chapters on ADO, but they are pretty comprehensive.

    Programming Microsoft Visual Basic .NET - Francesco Balena

    http://www.amazon.com/exec/obidos/tg...97645?v=glance

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Jul 2004
    Posts
    20
    Thanks for all of your Help!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width