Monday, February 6, 2012

Row already belongs to another table

November 1, 2009 by · Leave a Comment 

When copying a row from one datatable to another you might get the error "this row already belongs to another table". Typically you might write code like this: string sConnString = ConfigurationManager.ConnectionStrings["NorthwindConn"].ConnectionString; DataSet ds = Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteDataset(sConnString,CommandType.Text, "select * from suppliers order by supplierid"); int nRowCount = 0; DataTable dt = ds.Tables[0];DataTable dt2 = dt.Clone(); dt2.Clear(); [...]

Different operations on Datatable (Add, Edit, delete, Sort etc) and XML

November 1, 2009 by · 6 Comments 

Introduction DataTable is a central object in the ADO.NET library. If you are working with ADO.NET – accessing data from database, you can not escape from DataTable. Other objects that use DataTable are DataSet and DataView. In this tutorials, I will explain how to work with DataTable. I have tried to cover most of the [...]