Additional information: Cannot find table 0. DataGridView

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ksjoecho
    New Member
    • Apr 2015
    • 3

    Additional information: Cannot find table 0. DataGridView

    An unhandled exception of type 'System.IndexOu tOfRangeExcepti on' occurred in System.Data.dll

    Additional information: Cannot find table 0.
    Code:
       Dim MyDataMiscSource As New DataSet
    
       DBConnMisc = New SqlConnection _
                       ("Data Source=192.168.1.62;Initial Catalog=MyFirstDB;User ID=myuser;Password=mypassword")
           
       ConnectionCMD = New SqlCommand(SQLQueryMisc, DBConnMisc)
    
       DBConnMisc.Open()
            adapterSQLQueryMisc.SelectCommand = ConnectionCMD
         
       MiscDGV.Refresh()
    
       adapterSQLQueryMisc.Fill(MyDataMiscSource)
           
       adapterSQLQueryMisc.Dispose()
    
       ConnectionCMD.Dispose()
    
       DBConnMisc.Close()
    
       MiscDGV.Refresh()
    
       With MiscDGV
          .DataSource = MyDataMiscSource.Tables(0)
          .Columns(0).Width = 170
          .Columns(1).Width = 80
       End With
    when I run the application, I am getting an error from the line.
    Code:
    DataSource = MyDataMiscSource.Tables(0)
    An unhandled exception of type 'System.IndexOu tOfRangeExcepti on' occurred in System.Data.dll

    Additional information: Cannot find table 0.

    How can I solve this error?
    Last edited by zmbd; Apr 26 '15, 02:07 PM. Reason: [Z{2nd post explains first}{Please use the [CODE/] button to format posted script and formatted text - Please read the FAQ}]
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    Please attempt to run your compiler and step thru your code first.
    Sounds like your connection isn't valid or you have the table index wrong.

    Comment

    • ksjoecho
      New Member
      • Apr 2015
      • 3

      #3
      I think the table index issue.
      How can i fix the index.

      Better yet. I think the table is not filled.

      Can you help?

      Comment

      • zmbd
        Recognized Expert Moderator Expert
        • Mar 2012
        • 5501

        #4
        I do not do very much dot-net work so we'll have to wait for one of the other experts to wake-up and take a look at the site.
        Meantime it would be a good idea to step thru you code and make sure that the connection opened and that the data actually transferred when you called adapterSQLQuery Misc.Fill(MyDat aMiscSource)

        Comment

        • ksjoecho
          New Member
          • Apr 2015
          • 3

          #5
          It looks like I am getting a different error below:

          An unhandled exception of type 'System.Argumen tOutOfRangeExce ption' occurred in mscorlib.dll

          Additional information: Index was out of range. Must be non-negative and less than the size of the collection.

          Comment

          Working...