J
JT
I have an SQL database with one table in it. I want to load the table into
a DataSet, add new records to the DataSet, then commit the changes back to
the database.
Using C#.NET, the following loads the DataSet and fills it:
string SelectString = "SELECT * FROM dbo.Trade";
SqlCommand RecordsSelection = new SqlCommand(SelectString,
ThisConnection);
RecordsSelection.CommandTimeout = 10;
SqlDataAdapter TradeAdapter = new SqlDataAdapter();
TradeAdapter.SelectCommand = RecordsSelection;
DataSet TradeRecords = new DataSet();
TradeAdapter.Fill(TradeRecords, "dbo.Trade");
Now I want to access the single table and add a new row. I can iterate
through the tables collection of the dataset, but for each table, there is
no name property.
So my question is, how can I access a table within this dataset so I can add
a new row?
I know this question is elementary, but I would appreciate any help as
research has not answered the question.
Thanks.
a DataSet, add new records to the DataSet, then commit the changes back to
the database.
Using C#.NET, the following loads the DataSet and fills it:
string SelectString = "SELECT * FROM dbo.Trade";
SqlCommand RecordsSelection = new SqlCommand(SelectString,
ThisConnection);
RecordsSelection.CommandTimeout = 10;
SqlDataAdapter TradeAdapter = new SqlDataAdapter();
TradeAdapter.SelectCommand = RecordsSelection;
DataSet TradeRecords = new DataSet();
TradeAdapter.Fill(TradeRecords, "dbo.Trade");
Now I want to access the single table and add a new row. I can iterate
through the tables collection of the dataset, but for each table, there is
no name property.
So my question is, how can I access a table within this dataset so I can add
a new row?
I know this question is elementary, but I would appreciate any help as
research has not answered the question.
Thanks.