Clone Method (SqlCommand)
Creates a new object that is a copy of the current
SqlCommand instance.
|
|---|
'Declaration
Public Function Clone() As SqlCommand |
Return Value
A new
SqlCommand object in which all property values are the same as the original.
This example shows how to clone a
SqlCommand . To make sure all the properties are inherited, one of them (CommandText) is written to the console.
|
|---|
public void CloneACommand()
{
SqlCommand sqlCommand = new SqlCommand("SELECT * FROM Test.Dept");
SqlCommand sqlCommand2 = (SqlCommand)sqlCommand.Clone();
Console.WriteLine(sqlCommand2.CommandText);
} |
|
|---|
Public Sub CloneACommand()
Dim sqlCommand As New SqlCommand("SELECT * FROM Test.Dept")
Dim sqlCommand2 As SqlCommand = CType(sqlCommand.Clone(), SqlCommand)
Console.WriteLine(sqlCommand2.CommandText)
End Sub |