clonar un DataTable Con ImportRow c#

El siguiente Método explica como clonar un DataTable:
 

private DataTable GetOwnersTable()

{

//se llena el primer DataTable

DataTable databaseTable = this._databaseSupport.Owners;

//nueva dataTable para realizar una copia del anterior "databaseTable"

DataTable newTable = databaseTable.Clone();

//se recorren la filas del primer dataTable

for (int i = 0; i < databaseTable.Rows.Count; i++)

{

// Se obtiene la fila actual del dataTable original

DataRow row = databaseTable.Rows[i];

//se adiciona la fila al nuevo DataTable

newTable.ImportRow(row);

}

//Retorno el DataTable clonado

return newTable;

}

About omaracostacasas

ING SOFTWARE
This entry was posted in Microsoft .NET. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s