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 .
thanks.VB Code:
Public Function Nu_of_Rows(ByVal TableStr As String) Dim CmdText As String = "Select * FROM " & TableStr Dim ds As New DataSet() Dim adp As New OleDbDataAdapter(CmdText, MyConnection) adp.Fill(ds) 'This won't work MsgBox(ds.Tables(TableStr).Rows.Count) 'but this works fine MsgBox(ds.Tables(0).Rows.Count) End Function





Reply With Quote