Printing data from an OleDbDataReader in C#

Basically just for debugging purposes i want to print the contents of my OleDbDataReader object to the console, but i am really struggling to find away of doing it. Could someone help me out please. I have no way of testing my sql (well i can in toad for oracle but thats not the point).

Ideally i am going to transfer the contents of this in to an arraylist if they exist in c# (i am new to c# as you may have guessed!)

while (myOleDbDataReader.Read())


For every field in your Sql-Query, you can get the Data with typing

String test = myOleDbDataReader["fieldName"].ToString();

for example you can print it with:


You can try something like this

foreach(var item in myOleDbDataReader)

to print out every included item. (NOT tested!)

EDIT: Forgot that you have to put the foreach-loop in your while( or it won't work...


better Loop:

            for (int k = 0; k < reader.FieldCount; k++)

Need Your Help

Sublime Text 2 how to wrap selection with quotes/auto-pairing

autocomplete editor textmate text-editor sublimetext2

I just switched from Textmate 2 to Sublime Text 2. I figured that typing single quotes or brackets would automatically generate a second quote or bracket with the cursor in between ("auto-pairing" is

Dropdown Menu over SVG?

javascript html html5 svg d3.js

I have an svg canvas full of interesting data visualizations using d3 and I'd like to have a traditional html dropdown menu appear above an svg:rect element. Is this possible? I realize I could use

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.