DB2®BulkCopy.WriteToServer(System.Data.IDataReader) Method
Copies all rows from the DataReader to a 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 ( dataReader As IDataReader )
[C#]
public void WriteToServer ( IDataReader dataReader )
[C++]
public:
void WriteToServer ( IDataReader* dataReader )
[JScript]
public function WriteToServer ( dataReader : IDataReader )
Parameters
- dataReader
- An IDataReader object whose rows will be copied to the destination table.
Remarks
To avoid an InvalidOperationException, the DB2BulkCopy instance needs a DB2Connection instance that is distinct from the one being used by the DB2DataReader.
Example
[C#] The following example demonstrates a bulk copy of data from a DB2DataReader into the SALES table.
[C#]
public static void copyIntoSales(DB2Connection conn, DB2DataReader reader)
{
DB2BulkCopy salesCopy = new DB2BulkCopy(conn);
salesCopy.DestinationTableName = "SALES";
try
{
salesCopy.WriteToServer(reader);
salesCopy.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "Exception");
}
}