DB2®BulkCopy.WriteToServer(System.Data.DataTable, System.Data.DataRowState) Method
Copies only the rows in the specified state (indicated in DataRowState) from the DataTable to the destination table specified by the DestinationTableName property.
- Namespace:
IBM.Data.DB2
- Assembly:
IBM.Data.DB2
(inIBM.Data.DB2.dll
)
Syntax
[Visual Basic]
Public Sub WriteToServer ( _
dataTable As DataTable, _
rowState As DataRowState _
)
[C#]
public void WriteToServer (
DataTable dataTable,
DataRowState rowState
)
[C++]
public:
void WriteToServer (
DataTable* dataTable,
DataRowState rowState
)
[JScript]
public function WriteToServer (
dataTable : DataTable,
rowState : DataRowState
)
Parameters
- dataTable
- A DataTable object whose rows will be copied to the destination table.
- rowState
- The DataRowState enumeration value, specifying the state of rows to be copied to the destination table.
Remarks
The allowable states that can be specified by DataRowState are Added, Changed and Unmodified.
Example
[C#] The following example demonstrates a bulk copy of data from a DataTable source into the SALES table.
[C#]
public static void copyIntoSales(DB2Connection conn, DataTable source)
{
DB2BulkCopy salesCopy = new DB2BulkCopy(conn);
salesCopy.DestinationTableName = "SALES";
try
{
salesCopy.WriteToServer(source, DataRowState.Unchanged);
salesCopy.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "Exception");
}
}