January 27, 2011 at 8:56 am
Hi,
I have a dataset, which has stored some table, I want to create a same table on the same database, and same the data in the dataset to the new table, the following code can run, but I don't know why I can't find the table DT1 in my database, is there any step I missed? could you please help me check it? Thanks a lot.
Thanks
Lindsay
DataTable dt1 = new DataTable("DT1");
DataTable table = result.DataSet.Tables;
int columnCount = table.Columns.Count;
for (int columnIndex = 0; columnIndex < columnCount; columnIndex++)
{
dt1.Columns.Add(table.Columns[columnIndex].ColumnName, table.Columns[columnIndex].DataType);
}
result.DataSet.Tables.Add(dt1);
January 27, 2011 at 9:53 am
a datatable is a local object that exists in memory until you call UpdateDataTable from your DataAdapter, which would synchronize any changes....
typically you would use a typed dataset that has the exact structure of the table on the server, LoadDataTable, make changes, then UpdateDataTable to get the changes out to the server.
does that sound like what you are missing?
dt1 would not exist anywhere...the table you would look for would be the value found in result.DataSet.Tables.TableName or dt1.TableName
somewhere i'm expecting myDataAdapter.UpdateDataTable(result.DataSet.Tables😉
Lowell
January 28, 2011 at 8:39 am
Yes, you are right. Thanks a lot:)
Thanks
Lindsay
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply