| | |
SQL DataReader
Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Nov 2006
Posts: 3
Reputation:
Solved Threads: 0
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.
Thanks
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.
Thanks
•
•
Join Date: Nov 2006
Posts: 436
Reputation:
Solved Threads: 72
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,
Jerry
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,
Jerry
SqlDataReader ogRdr = command.ExecuteReader(); while (ogRdr.Read()) { Object[] values = new Object[ogRdr.FieldCount]; ogRdr.GetValues(values); node = treeOperGroup.Nodes.Add((string)ogRdr[COL_OPERGROUPNAME]); node.Tag = values; }
![]() |
Similar Threads
- how to insert data into the database in vb.net using textfields. (VB.NET)
- HOWTO: Share an SQL Connection between multiple forms within the same project (C#)
- SQL Server, Images and DataGrid in ASP.NET (ASP.NET)
- SQL Server vs MYSQL vs MSQL (i'm stopping now) (MS SQL)
Other Threads in the C# Forum
- Previous Thread: SqlDataReader
- Next Thread: Trying to obtain text from a file.
| Thread Tools | Search this Thread |
.net access ado.net algorithm array barchart bitmap box broadcast buttons c# c#gridviewcolumn chat check checkbox client color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees development draganddrop drawing encryption enum event excel file files form format forms function gdi+ httpwebrequest image index input install java label list listbox listener localization mandelbrot math mouseclick mysql networking object operator path photoshop picturebox pixelinversion post prime programming radians regex remote remoting richtextbox save saving serialization server sleep socket sql statistics stream string table tcp text textbox thread time timer treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml





