dotConnect for DB2 Documentation
Devart.Data.DB2 Namespace / DB2Loader Class / DB2Loader Constructor / DB2Loader Constructor(String,DB2Connection)
Name of the table that will be loaded.
A DB2Connection object that represents the connection to a data source.
Example

In This Topic
    DB2Loader Constructor(String,DB2Connection)
    In This Topic
    Initializes a new instance of the DB2Loader class with table name that will be loaded and a DB2Connection object.
    Syntax
    'Declaration
     
    Public Function New( _
       ByVal tableName As String, _
       ByVal connection As DB2Connection _
    )
    public DB2Loader( 
       string tableName,
       DB2Connection connection
    )

    Parameters

    tableName
    Name of the table that will be loaded.
    connection
    A DB2Connection object that represents the connection to a data source.
    Remarks
    Use this constructor to set TableName and Connection properties at the time of initialization.
    Example
    The following example creates a DB2Loader and sets some of its properties. Then prepares data and loads it into the table.
    public void CreateMyLoader()
    {
      // Create and open connection
      DB2Connection conn = new DB2Connection(
          "user id=db2admin;server=db2;database=SAMPLE;");
      conn.Open();
    
      // Create loader instance
      DB2Loader loader = new DB2Loader("loader_test", conn);
         
      // Prepare for loading
      loader.Open();
    
      // Set row values
      for (int i = 0; i < 10000; i++) {
        loader.SetValue(0, i);
        loader.SetValue(1, "test string");
        loader.SetValue(2, DateTime.Now);
        // Load next table row
        loader.NextRow();
      }
    
      // Flush buffer and finish loading
      loader.Close();
    }
    Public Sub CreateMyLoader()
      ' Create and open connection
      Dim conn As DB2Connection = new DB2Connection( _
          "user id=db2admin;server=db2;database=SAMPLE;")
      conn.Open()
    
      ' Create loader instance
      Dim loader As DB2Loader = new DB2Loader("loader_test", conn)
         
      ' Prepare for loading
      loader.Open()
    
      ' Set row values
      Dim i As Integer
      For i = 0 To 10000
        loader.SetValue(0, i)
        loader.SetValue(1, "test string")
        loader.SetValue(2, DateTime.Now)
        ' Load next table row
        loader.NextRow()
      next
    
      ' Flush buffer and finish loading
      loader.Close()
    End Sub
    See Also