Results 1 to 3 of 3

Thread: Number of rows?[Resolved]

Threaded View

  1. #1

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    Number of rows?[Resolved]

    This code won't run if provided table name but will work when I give 0 to (ds.Tables(0).Rows.Count) . The error I get is : Object reference not set to an instance of an object .

    VB Code:
    1. Public Function Nu_of_Rows(ByVal TableStr As String)
    2. Dim CmdText As String = "Select * FROM " & TableStr
    3. Dim ds As New DataSet()
    4. Dim adp As New OleDbDataAdapter(CmdText, MyConnection)
    5. adp.Fill(ds)
    6.  
    7. 'This won't work
    8. MsgBox(ds.Tables(TableStr).Rows.Count)
    9.  
    10. 'but this works fine
    11. MsgBox(ds.Tables(0).Rows.Count)
    12. End Function
    thanks.
    Last edited by Pirate; Apr 26th, 2003 at 09:26 AM.

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