Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27514

VS 2010 Reader returns nothing from MySQL

$
0
0
I have been trying to sort this out but I must be missing something and was wondering if someone can take a quick look.

VB.Net Code:
  1. Dim datTab As DataTable = Nothing
  2. Dim strSQLText As String = ""
  3. Dim reader As MySqlDataReader = Nothing
  4. Dim strSQLCmd As New MySqlCommand
  5.  
  6. strSQLText = "My SQL Statement"
  7.  
  8. strSQLCmd.CommandText = strSQLText
  9. strSQLCmd.Connection = myConnection
  10.      
  11. reader = strSQLCmd.ExecuteReader
  12.  
  13. datTab.Load(reader)

I have tested my SQL statement and I created and tested it in SQLyog so I removed it to keep the post short. In fact, I moved it back to SQLyog to test. My connection is declared at the module level and is open.

The code errors at the datatable load statement with "Object reference not set to an instance of an object."

The reader is returning nothing which is causing the error, but I can't figure out why it is returning nothing. It should return over 180 rows.

Can anyone point me in the right direction to figure this out?

TIA, rasinc

Viewing all articles
Browse latest Browse all 27514

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>