dotConnect for DB2 Documentation
Devart.Data.DB2 Namespace / DB2Connection Class / Clone Method
Example

In This Topic
    Clone Method (DB2Connection)
    In This Topic
    Creates a new object that is a copy of the current instance.
    Syntax
    'Declaration
     
    Public Function Clone() As DB2Connection
    public DB2Connection Clone()

    Return Value

    A new DB2Connection object.
    Remarks

    Creates a new DB2Connection object with the properties that have the same values as those of the original object. However, changing properties of the new object has no influence on the values of the same properties of the original object.

    Note that state of the new instance is always Closed, regardless of the state of original instance.

    Example
    This example shows how to clone a DB2Connection. To make sure all the properties are inherited, one of them (UserId) is written to the console.
    public void CloneAConnection()
    {
      DB2Connection db2Connection = new DB2Connection(
          "user id=db2admin;server=db2;database=SAMPLE;");
      DB2Connection db2Connection2 = (DB2Connection)db2Connection.Clone();
      Console.WriteLine(db2Connection2.UserId);
    }
    Public Sub CloneAConnection()
      Dim db2Connection As New DB2Connection( _
          "user id=db2admin;server=db2;database=SAMPLE;")
      Dim db2Connection2 As DB2Connection = CType(db2Connection.Clone(), DB2Connection)
      Console.WriteLine(db2Connection2.UserId)
    End Sub
    Requirements

    Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also