Jagadish's profileJagadish Pulakhandam'sPhotosBlogListsMore ![]() | Help |
|
April 24 TIP: Copying rows from a DataView to a new DataTableIn an ASP.NET app, I had a need to copy the data from a DataView to a DataTable for additional manipulation of the rows (without effecting the original table that the DataView was created on). Came across this:
C# version (used conversion tool)
======================
private DataTable DataViewAsDataTable(DataView dv)
{
DataTable dt = dv.Table.Clone(); foreach (DataRowView dvr in dv) {
dt.ImportRow(dvr.Row); } dt.AcceptChanges; return dt; } VB.NET version (used conversion tool) =========================
Private Function DataViewAsDataTable(ByVal dv As DataView) As DataTable
Dim dt As DataTable = dv.Table.Clone For Each dvr As DataRowView In dv dt.ImportRow(dvr.Row) Next dt.AcceptChanges Return dt End Function April 12 Northwind database scripts for Oracle"Northwind" is a demonstration database provided by Microsoft. It is generally available with Access or SQL Server 2000. I generated Oracle script for the same Northwind database (along with INSERT statements), to make it available as a demonstration database for Oracle as well.
You can find the scripts here:
http://www.codekeep.net/snippets/41e9fa59-9013-450e-9409-893f08deef7b.aspx (Creating tables)
http://www.codekeep.net/snippets/fbe729d2-91b3-4dbe-a076-6a4477c68a5c.aspx (Inserting data) http://www.codekeep.net/snippets/5f9ae60d-683a-4e59-9b9e-92bb39f7c4ab.aspx (Dropping tables) UPDATE:
Another script is available here: http://www.codeplex.com/entlib/WorkItem/View.aspx?WorkItemId=12491
Note:
Feedback is well appreciated and I will keep on updating the utility based on your feedback.. thanks Jag April 02 Part 3: More about CASE, @@ROWCOUNT and TABLES in T-SQLHello,
This is third in series focusing on the following topics:
The article is available at http://www.aspfree.com/c/a/MS-SQL-Server/Using-ROWCOUNT-and-TABLE-Variables-for-Database-Interactions-with-TransactSQL/ thanks Jag |
|
|