Posts

Showing posts from February, 2014

Insert ,Update and Delete in DataTable using c#

Insert ,Update and Delete in DataTable using c# Creating DataTable DataTable dt= new DataTable (); DataColumn columnAutoID = new DataColumn ( "AutoID" , typeof ( int )); columnAutoID.AutoIncrement = true ; columnAutoID.AutoIncrementSeed = 1; dt.Columns.Add(columnAutoID); dt.Columns.Add( new DataColumn ( "Name" , typeof ( string ))); dt.Columns.Add( new DataColumn ( "Address" , typeof ( string ))); dt.Columns.Add( new DataColumn ( "Phone" , typeof ( int ))); dt.Columns.Add( new DataColumn ( "UpdateStatus" , typeof ( int ))); Adding New row witrh data in DataTable DataRow row = dt.NewRow(); row[ "Name " ] = “kandy”; row[ "Address " ] = “India”; row[ "Phone " ] = “888888888”; row[ "UpdateStatus " ] = “0”; dt.Rows.Add(row); Updating DataTable when UpdateStatus=0   DataRow [] rows = dt.Select( "UpdateStatus =" + 0); if ...