Try ' Open a connection. cn.Open() dr = cmd.ExecuteReader() ' Display all fields Do While dr.Read Dim res As String = "" Dim i As Integer ' Iterate over all fields. For i = 0 To dr.FieldCount - 1 ' Insert a comma if necessary. If res.Length > 0 Then res &= ", " ' Append field name and value. res &= dr.GetName(i) & "=" If dr.IsDBNull(i) Then res &= "<NULL>" Else res &= dr.GetValue(i).ToString End If Next ' Append to the result textbox. txtOut.AppendText(res & ControlChars.CrLf) Loop dr.Close() Catch ex As OleDbException Debug.WriteLine(ex.Message) Finally ' Close the connection. cn.Close() End Try |