I Have a Just Simple Question. But It Made me Confuse. I have a DataTable Which has bind to textBoxes and Other Items. therfore when I made a change through txtBox or Other Items it reflect to dataTable. what I have to do is Saving updated Datatable to Sql Table. I tried to use Adapter. but we have to use a select Command there we can't use it.. please help me..
dinesh.isuranga
0
Newbie Poster
Recommended Answers
Jump to PostProvided the table has a primary key, you can easily generate the SQL to update with a SqlCommandBuilder and actually do the updates with a SqlDataAdapter:
using (var cmd = new SqlCommand(selectQuery, connection)) { using (var da = new SqlDataAdapter(cmd)) { using (var cb = new SqlCommandBuilder(da)) …
Jump to Postso if i use this code my datatable will override with this select ststement
That's not correct. The select query is required by SqlCommandBuilder for generating insert, update, and delete statements. The select statement isn't run to refill the table unless you call the Fill method of your data adapter …
All 8 Replies
Narue
5,707
Bad Cop
Team Colleague
dinesh.isuranga
0
Newbie Poster
Narue
5,707
Bad Cop
Team Colleague
dinesh.isuranga
0
Newbie Poster
Narue
5,707
Bad Cop
Team Colleague
kvprajapati
1,826
Posting Genius
Team Colleague
dinesh.isuranga
0
Newbie Poster
dinesh.isuranga
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.