DataTable.clear method

xiaoxiao2021-03-06  20

Clear the DataTable of all data.

[Visual Basic]

Public Sub Clear ()

[C #]

Public void clear ();

[C ]

PUBLIC: VOID CLEAR ();

[Jscript]

Public function clear ();

Note

All rows in all tables are removed. If there is any powerful sub-relationship that will affect the marks in the table, an exception is generated.

If the DataSet is bound to XMLDATADOCUMENT, call DataSet.clear or DataTable.clear will raise NotSupportedException. To avoid this, please traverse each table and remove each row one by one.

Example

[Visual Basic, C #, C ] The following example clears the table of all data.

[Visual Basic]

Private Sub Cleartable (MyTable as DataTable)

Try

myTable.clear ()

Catch e as dataException

'Process Exception and Return.

DIM log as system.diagnostics.eventlog = new system.diagnostics.eventlog ()

Log.Source = "My Application"

Log.writentry (E.TOString ())

Console.writeline ("Exception of type {0} Occurred.", E.GETTYPE (). TOSTRING ())

END TRY

End Sub

[C #]

Private void cleartable (DataTable myTable) {

Try {

MyTable.clear ();

}

Catch (DataException E) {

// Process Exception and Return.

System.Diagnostics.eventlog log = new system.diagnostics.eventlog ();

Log.Source = "my application";

Log.WriteEntry (e.tostring ());

Console.writeline ("Exception of type {0} Occurred.", E.GETTYPE ());

}

}

[C ]

Private:

Void Cleartable (DataTable * MyTable) {

Try {

MyTable-> clear ();

}

Catch (DataException * e) {

// Process Exception and Return.

System :: Diagnostics :: EventLog * log = new system :: Diagnostics :: EventLog ();

LOG-> Source = s "My Application";

LOG-> WriteEntry (e-> toString ());

Console :: WriteLine (S "Exception of type {0} Occurred.", E-> gettype ());

}

}

[JScript] There is no example available for JScript. To view Visual Basic, C # or C examples, click the "Language Filter" button in the upper left corner.

Claim

Platform: Windows 98, Windows NT 4.0, Windows Me, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 Series, .NET FRAMEWORK Lite, please see

DataTable class | DataTable member | system.data namespace

转载请注明原文地址:https://www.9cbs.com/read-42840.html

New Post(0)