T
TG
Can someone spot my error in this code? I get the error message
"Object reference not set to an instance of an object." when I attempt
to read from the OleDbDataReader.
Thanks
BTW, I posted this yesterday, but I don't see it in the NG. My
apologies if this turns out to be a second posting.
******************************
Private Sub Test2()
Dim ConnString As String = "Provider=Microsoft.Jet.OLEDB.4.0;"
& _
"Data Source=c:\;" & _
"Extended Properties='text;HDR=Yes;FMT=Delimited'"
Dim Conn As New OleDbConnection(ConnString)
Dim Qry As String = "SELECT * from Global-List.txt"
Dim Cmd As New OleDbCommand(Qry, Conn)
Dim Dr As OleDbDataReader
Conn.Open()
Try
Dr = Cmd.ExecuteReader(CommandBehavior.CloseConnection)
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
While Dr.Read 'Object reference not set to an instance of an
object.
Console.WriteLine(Dr.GetString(0))
End While
Dr.Close()
End Sub
"Object reference not set to an instance of an object." when I attempt
to read from the OleDbDataReader.
Thanks
BTW, I posted this yesterday, but I don't see it in the NG. My
apologies if this turns out to be a second posting.
******************************
Private Sub Test2()
Dim ConnString As String = "Provider=Microsoft.Jet.OLEDB.4.0;"
& _
"Data Source=c:\;" & _
"Extended Properties='text;HDR=Yes;FMT=Delimited'"
Dim Conn As New OleDbConnection(ConnString)
Dim Qry As String = "SELECT * from Global-List.txt"
Dim Cmd As New OleDbCommand(Qry, Conn)
Dim Dr As OleDbDataReader
Conn.Open()
Try
Dr = Cmd.ExecuteReader(CommandBehavior.CloseConnection)
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
While Dr.Read 'Object reference not set to an instance of an
object.
Console.WriteLine(Dr.GetString(0))
End While
Dr.Close()
End Sub