Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Feb 26, 2012 12:11 AM by Decker Dong - MSFT
Participant
1218 Points
360 Posts
Feb 24, 2012 11:08 AM|LINK
Hi All,
Can any one let me know "How to update the data in a particular column of a datatable without running forloop or foreach loop in .Net 2.0"?
Thanks and Regards,
G.V.N.Sandeep
Contributor
2412 Points
415 Posts
Feb 24, 2012 07:56 PM|LINK
You need to update all of the rows value for a specific column ?
Not just myDataTable.Rows[aspecificRow][TheColumnIneedtoupdate], but all myDataTable.Rows[][TheColumnIneedtoupdate] ?
5132 Points
1465 Posts
Feb 25, 2012 01:09 AM|LINK
babji.sunny@gmail.com G.V.N.Sandeep
There's a bit different between EF 4.0 and 4.1 and I don't know which one are you using......So this is EF 4.1.
public void UpdateEntity(Entity entity)
{
this.DbContext.Entry(entity).State = EntityState.Modified;
}
Member
194 Points
69 Posts
Feb 25, 2012 03:58 PM|LINK
you can convert the datatable in xml and insert using stored procedure.
This is the most effective and efficient way to insrt data with multiple rows.
All-Star
118619 Points
18779 Posts
Feb 26, 2012 12:11 AM|LINK
Hello babij:)
Just use SqlDataAdapter:
1)Use SqlCommandBuilder to generate CRUD。
2)Use SqlDataAdapter.Fill(DataTable)。
3)Then do modifications to the DataTable,and then use SqlDataAdapter.Update(DataTableRow),one row will be upgrated。
babji.sunny@...
Participant
1218 Points
360 Posts
How to update the data in a datatable without running for loop in .Net 2.0?
Feb 24, 2012 11:08 AM|LINK
Hi All,
Can any one let me know "How to update the data in a particular column of a datatable without running forloop or foreach loop in .Net 2.0"?
Thanks and Regards,
G.V.N.Sandeep
This can be beneficial to other community members reading the thread
texx
Contributor
2412 Points
415 Posts
Re: How to update the data in a datatable without running for loop in .Net 2.0?
Feb 24, 2012 07:56 PM|LINK
You need to update all of the rows value for a specific column ?
Not just myDataTable.Rows[aspecificRow][TheColumnIneedtoupdate], but all myDataTable.Rows[][TheColumnIneedtoupdate] ?
thaicarrot
Contributor
5132 Points
1465 Posts
Re: How to update the data in a datatable without running for loop in .Net 2.0?
Feb 25, 2012 01:09 AM|LINK
There's a bit different between EF 4.0 and 4.1 and I don't know which one are you using......So this is EF 4.1.
public void UpdateEntity(Entity entity)
{
this.DbContext.Entry(entity).State = EntityState.Modified;
}
Weera
tej narayan
Member
194 Points
69 Posts
Re: How to update the data in a datatable without running for loop in .Net 2.0?
Feb 25, 2012 03:58 PM|LINK
you can convert the datatable in xml and insert using stored procedure.
This is the most effective and efficient way to insrt data with multiple rows.
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: How to update the data in a datatable without running for loop in .Net 2.0?
Feb 26, 2012 12:11 AM|LINK
Hello babij:)
Just use SqlDataAdapter:
1)Use SqlCommandBuilder to generate CRUD。
2)Use SqlDataAdapter.Fill(DataTable)。
3)Then do modifications to the DataTable,and then use SqlDataAdapter.Update(DataTableRow),one row will be upgrated。