imports System imports System.data imports sql = System.Data.SqlClient imports Microsoft.VisualBasic imports System.Collections public module MyModule sub Main NorthwindDataReaderUsingExecuteReaderOfCommandObject AnyKey end sub Private Sub NorthwindDataReaderUsingExecuteReaderOfCommandObject Dim strSQL as String = "user id=sa;integrated security=SSPI;data source='(local)';initial catalog=Northwind" WL("Connect String: ", strSQL) Dim cn AS new sql.SqlConnection cn.ConnectionString = strSQL Try ' Setup Command Dim cmd as new sql.SqlCommand cmd.CommandText = "SELECT [CompanyName] FROM [Customers]" cmd.CommandType = CommandType.Text cmd.Connection = cn Dim dr as sql.sqlDataReader cn.Open dr = cmd.ExecuteReader Do While dr.Read = True 'The following will all return the same results 'WL("Company Name", dr.Item(0)) 'WL("Company Name", dr.Item("CompanyName")) WL("Company Name", dr.GetString(0)) Loop dr.Close() cn.Close() Catch ex As Exception WL("Error", ex.Message.tostring) End Try End Sub sub WL(strItem as string, objValue as Object) ' paramarray Dim strValue As String = CType(objValue, String) Console.WriteLine(strItem & ": [" & strValue & "]") end sub sub WL(strItem as string) Console.WriteLine(strItem) end sub sub AnyKey WL("") Console.Write("Press enter key to continue... ") RL() end Sub sub RL() Console.ReadLine() end sub end module