Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Two ADO.NET questions...
Message
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Divers
Thread ID:
00699817
Message ID:
00699829
Vues:
16
See inline comments.

>1) Is there a function to copy the structure of a data table to another data table? (equivalent in VFP...COPY STRUCTURE TO...)
>

Use the DataTable.Clone method. Here is the sample code from the online help:
[Visual Basic] 
Private Sub GetClone(ByVal myDataTable As DataTable)
    ' Get a clone of the original DataTable.
    Dim cloneTable As DataTable
    cloneTable = myDataTable.Clone()
    ' Insert code to work with clone of the DataTable.
 End Sub

[C#] 
private void GetClone(DataTable myDataTable){
    // Get a clone of the original DataTable.
    DataTable cloneTable;
    cloneTable = myDataTable.Clone();
    // Insert code to work with clone of the DataTable.
 }
>2) Can a data table be 'zapped'? I realize I can delete every row, but was curious if there was a simple erase method to reset a data table to zero rows.

Use the Clear method of the DataRowCollection. Here is sample code from the online help:
[Visual Basic] 
Private Sub ClearTable(ByVal myTable As DataTable)
    Dim rc As DataRowCollection
    rc = myTable.Rows
    ' Clear all rows.
    rc.Clear
 End Sub

[C#] 
private void ClearTable(DataTable myTable){
    DataRowCollection rc; 
    rc = myTable.Rows;
    // Clear all rows.
    rc.Clear();
 }
>
>Thanks,
>Kevin
-----------------------------------------

Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.com
www.prenia.com
Weblog: blogs.prenia.com/cathi
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform