I have successfully got the data reader connected but i cannot figure out how to write the values to an array or variables on a windows form created in Visual C# Express edition all examples use the console.
Can someone show me an example of how to write these values to an array so that i can use that as my starting point to initialize the values on the windows form? This is really new to me and a little confusing.


10 Years
Discussion Span
Last Post by JerryShaw

Maybe this will shed some light on the subject.

I create an array of object[] that is populated by the current row when using the GetValues method of the SQLDataReader.
I have a set of constants to identify specif columns from the row, however you can use quoted column names instead.
A nice little trick is to save the entire row into the TAG property of my treeview as shown below. while ...Read() is the same thing as while not data.eof.

Have fun,

SqlDataReader ogRdr = command.ExecuteReader();
while (ogRdr.Read())
Object[] values = new Object[ogRdr.FieldCount];
node = treeOperGroup.Nodes.Add((string)ogRdr[COL_OPERGROUPNAME]);
node.Tag = values;
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.