DB2DataAdapter Constructor ()

Initializes a new instance of the DB2DataAdapter class.

Namespace:
IBM.Data.DB2
Assembly:
IBM.Data.DB2 (in IBM.Data.DB2.dll)

Syntax


[Visual Basic]
Public Sub New()
[C#]
public DB2DataAdapter();
[C++]
public: DB2DataAdapter();
[JScript]
public function DB2DataAdapter();

Remarks

When you create an instance of DB2®DataAdapter , the following read/write properties are set to their default values, as shown in the table.

Properties Default value
MissingMappingAction MissingMappingAction.Passthrough
MissingSchemaAction MissingSchemaAction.Add

You can change the value of any of these properties through a separate call to the property.

Example

[Visual Basic, C#] The following example creates a DB2DataAdapter and sets some of its properties.

[Visual Basic]
Public Sub CreateDB2DataAdapter()
    Dim myDB2Connection As DB2Connection = New DB2Connection("DATABASE=SAMPLE;")
    Dim empDA As DB2DataAdapter = New DB2DataAdapter
    empDA.MissingSchemaAction = MissingSchemaAction.AddWithKey

    Dim employeeDS As DataSet = New DataSet
    empDA.Fill(employeeDS, "EMPLOYEE")

    empDA.SelectCommand = New DB2Command(
      "SELECT EMPNO, LASTNAME FROM EMPLOYEE", myDB2Connection)
    empDA.InsertCommand = New DB2Command(
      "INSERT INTO EMPLOYEE (EMPNO, LASTNAME) " & _
      "VALUES (?, ?)", myDB2Connection)
    empDA.UpdateCommand = New DB2Command(
      "UPDATE EMPLOYEE SET EMPNO = ?, LASTNAME = ? " & _
      "WHERE EMPNO = ?", myDB2Connection)
    empDA.DeleteCommand = New DB2Command(
      "DELETE FROM EMPLOYEE WHERE EMPNO = ?", 
      myDB2Connection)

    empDA.InsertCommand.Parameters.Add("EMPNO", DB2Type.Char, 6, "EMPNO")
    empDA.InsertCommand.Parameters.Add("LASTNAME", DB2Type.VarChar, 15, "LASTNAME")

    empDA.UpdateCommand.Parameters.Add("EMPNO", DB2Type.Char, 6, "EMPNO")
    empDA.UpdateCommand.Parameters.Add("LASTNAME", DB2Type.VarChar, 15, "LASTNAME")
    empDA.UpdateCommand.Parameters.Add("OLDEMPNO", DB2Type.Char, 6, 
      "EMPNO").SourceVersion = DataRowVersion.Original

    empDA.DeleteCommand.Parameters.Add("EMPNO", DB2Type.Char, 6, 
      "EMPNO").SourceVersion = DataRowVersion.Original
End Sub

[C#]
public static void CreateDB2DataAdapter()
{
    DB2Connection myDB2Connection = new DB2Connection("DATABASE=SAMPLE;");
    DB2DataAdapter empDA = new DB2DataAdapter();
    empDA.MissingSchemaAction = MissingSchemaAction.AddWithKey;

    DataSet employeeDS = new DataSet();
    empDA.Fill(employeeDS, "EMPLOYEE");

    empDA.SelectCommand = new DB2Command(
      "SELECT EMPNO, LASTNAME FROM EMPLOYEE", myDB2Connection);
    empDA.InsertCommand = new DB2Command(
      "INSERT INTO EMPLOYEE (EMPNO, LASTNAME) " +
      "VALUES (?, ?)", myDB2Connection);
    empDA.UpdateCommand = new DB2Command(
      "UPDATE EMPLOYEE SET EMPNO = ?, LASTNAME = ? " +
      "WHERE EMPNO = ?", myDB2Connection);
    empDA.DeleteCommand = new DB2Command(
      "DELETE FROM EMPLOYEE WHERE EMPNO = ?", myDB2Connection);

    empDA.InsertCommand.Parameters.Add(
      "EMPNO", DB2Type.Char, 6, "EMPNO");
    empDA.InsertCommand.Parameters.Add(
      "LASTNAME", DB2Type.VarChar, 15, "LASTNAME");

    empDA.UpdateCommand.Parameters.Add(
      "EMPNO", DB2Type.Char, 6, "EMPNO");
    empDA.UpdateCommand.Parameters.Add(
      "LASTNAME", DB2Type.VarChar, 15, "LASTNAME");
    empDA.UpdateCommand.Parameters.Add(
      "OLDEMPNO", DB2Type.Char, 6, "EMPNO").SourceVersion = DataRowVersion.Original;

    empDA.DeleteCommand.Parameters.Add(
      "EMPNO", DB2Type.Char, 6, "EMPNO").SourceVersion = DataRowVersion.Original;
}