By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,745 Members | 1,897 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,745 IT Pros & Developers. It's quick & easy.

Additional information: Cannot find table 0. DataGridView

P: 3
An unhandled exception of type 'System.IndexOutOfRangeException' occurred in System.Data.dll

Additional information: Cannot find table 0.
Expand|Select|Wrap|Line Numbers
  1.    Dim MyDataMiscSource As New DataSet
  2.  
  3.    DBConnMisc = New SqlConnection _
  4.                    ("Data Source=192.168.1.62;Initial Catalog=MyFirstDB;User ID=myuser;Password=mypassword")
  5.  
  6.    ConnectionCMD = New SqlCommand(SQLQueryMisc, DBConnMisc)
  7.  
  8.    DBConnMisc.Open()
  9.         adapterSQLQueryMisc.SelectCommand = ConnectionCMD
  10.  
  11.    MiscDGV.Refresh()
  12.  
  13.    adapterSQLQueryMisc.Fill(MyDataMiscSource)
  14.  
  15.    adapterSQLQueryMisc.Dispose()
  16.  
  17.    ConnectionCMD.Dispose()
  18.  
  19.    DBConnMisc.Close()
  20.  
  21.    MiscDGV.Refresh()
  22.  
  23.    With MiscDGV
  24.       .DataSource = MyDataMiscSource.Tables(0)
  25.       .Columns(0).Width = 170
  26.       .Columns(1).Width = 80
  27.    End With
when I run the application, I am getting an error from the line.
Expand|Select|Wrap|Line Numbers
  1. DataSource = MyDataMiscSource.Tables(0)
An unhandled exception of type 'System.IndexOutOfRangeException' occurred in System.Data.dll

Additional information: Cannot find table 0.
How can I solve this error?
Apr 26 '15 #1
Share this Question
Share on Google+
4 Replies


zmbd
Expert Mod 5K+
P: 5,397
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.
Apr 26 '15 #2

P: 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?
Apr 26 '15 #3

zmbd
Expert Mod 5K+
P: 5,397
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 adapterSQLQueryMisc.Fill(MyDataMiscSource)
Apr 26 '15 #4

P: 3
It looks like I am getting a different error below:

An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll

Additional information: Index was out of range. Must be non-negative and less than the size of the collection.
Apr 26 '15 #5

Post your reply

Sign in to post your reply or Sign up for a free account.