-
April 21st, 2007, 01:18 PM
#1
[RESOLVED] [NOOB] Simple ado.net question
How do I add data that is in memory to a dataset so that I can execute sql queries on it in order to return something that I can manage in a while or foreach loop?
Basically I have a file with data, that I'd like to be able to execute sql on to sort it. Something along these lines
while(not EOF)
{
Read data from file
add data to dataset
}
execute query on dataset
foreach row in dataset
{
create a treeview node for row.field
}
This should be simple.
-
April 21st, 2007, 02:13 PM
#2
Re: [NOOB] Simple ado.net question
Nevermind. I figured it out.
Create a dataset
DataSet dataset = newDataSet("My Dataset");
Create a table
DataTable datatable = dataKeyLog.Tables.Add("My Data Table");
Add columns to table
datatable.Columns.Add("Column 1");
datatable.Columns.Add("Column 2");
datatable.Columns.Add("Column 3");
Create a new row
DataRow row = datatable.NewRow();
Populate the new row with data
row["Column 1"] = "whatever data is appropriate"
row["Column 2"] = "whatever data is appropriate"
row["Column 3"] = "whatever data is appropriate"
Add the row to the table
datatable.Rows.Add(row);
Create a data view
DataView dataview = newDataView();
dataview.Table = datatable;
Last edited by Traps; April 21st, 2007 at 07:55 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|