Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Adding DataTable to DataSet
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
C# 3.0
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01343220
Message ID:
01343272
Vues:
15
BTW, re-check my reply, please. I updated it with the links I found (one is the same as your answer), but you seem to reply on my original question before my update.

>>Hi everybody,
>>
>>I found this link http://msmvps.com/blogs/egoldin/archive/2006/12/27/how-to-get-datatable-out-of-sqldatasource.aspx
>>
>>So, I can get the DataTable.
>>
>>I need to create a dataset with this data and save it to the session.
>>
>>Do you know how can I do this?
>>
>>Can I somehow cast DataTable to DataSet?
>>
>
>No, but you can add a DataTable to a DataSet (as long as the DataTable doesn't already belong to another DataSet), ex:
>
>
>DataSet ds = new DataSet();
>// Retrieve the table from wherever
>DataTable table = new DataTable("TableName");
>ds.Tables.Add(table);
>
>
>If it's already part of a DataSet (ex. you can tell by checking to see if the tables DataSet property is null or not), you'll get an error if you try assigning it to another DataSet. If that's the case, you can copy the DataTable, then add the copy:
>
>
>if (table.DataSet != null)
>{
>    DataTable newTable = table.Copy()
>    ds.Tables.Add(newTable);
>}
>
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform