Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 2012/5.0 > BOOK: MCSD Certification Toolkit (Exam 70-483): Programming in C#
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: MCSD Certification Toolkit (Exam 70-483): Programming in C#
This is the forum to discuss the Wrox book MCSD Certification Toolkit (Exam 70-483): Programming in C# by Tiberiu Covaci, Rod Stephens, Vincent Varallo, Gerry O'Brien; ISBN: 978-1-118-61209-5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: MCSD Certification Toolkit (Exam 70-483): Programming in C# section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old January 6th, 2017, 07:44 AM
Registered User
Points: 13, Level: 1
Points: 13, Level: 1 Points: 13, Level: 1 Points: 13, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2017
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default chapter 9 update and delete records using dataadapter

Using codelab p387
we have prepopulated the da with update and delete commands via:
da.UpdateCommand = update;
da.DeleteCommand = delete;


what is the effect of the below. We have made modifications to the DS including updating the first row (ds.Tables[0].Rows[0]["FirstName"] = "Jack";) and deleting the second row(ds.Tables[0].Rows[1].Delete();).
What are we updating to the database via this command. i understand we are running update and delete sql statements but what are they ?
da.Update(ds.Tables[0]);
Reply With Quote
  #2 (permalink)  
Old January 6th, 2017, 07:48 AM
Registered User
Points: 13, Level: 1
Points: 13, Level: 1 Points: 13, Level: 1 Points: 13, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2017
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default potential response

is the effect of the da.Update(ds.Tables[0]); only to update the first record to Jack Johnson and delete the second record????????? what about all the other records in the DataSet?
Reply With Quote
  #3 (permalink)  
Old January 7th, 2017, 02:01 PM
Rod Stephens's Avatar
Wrox Author
Points: 3,145, Level: 23
Points: 3,145, Level: 23 Points: 3,145, Level: 23 Points: 3,145, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 641
Thanks: 2
Thanked 96 Times in 95 Posts
Default

See my reply to your earlier thread. The Update method uses the insert, updated, and delete command objects to update any records that are out of sync with the values in the database. It adds new records, updates modified ones, and removes deleted records.

Any records that have not been changed in the data set are not touched in the database to reduce the amount of data that must be transmitted back to the database server.

Again, reply if that doesn't make sense.
__________________
Rod

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)
Reply With Quote
  #4 (permalink)  
Old January 7th, 2017, 02:10 PM
Rod Stephens's Avatar
Wrox Author
Points: 3,145, Level: 23
Points: 3,145, Level: 23 Points: 3,145, Level: 23 Points: 3,145, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 641
Thanks: 2
Thanked 96 Times in 95 Posts
Default

Sorry, I missed this part:

Quote:
i understand we are running update and delete sql statements but what are they ?
The short answer is that the command objects (like the insert object) tell the data adapter how to insert, update, and delete data in the database.

This example sets the command text for the objects. For example, the insert command's text is:

Code:
INSERT INTO Students (FirstName, LastName)
VALUES (@FirstName, @LastName)


Then the code adds parameters that define the fields @FirstName and @LastName.

When you update the database, the command object basically loops through the new records, replaces @FirstName and @LastName with the record's values in the INSERT statement, and executes it. After the replacements, the command strings are something that the database can understand so it takes the necessary action, in this case inserting the records.

The update and delete objects (if they are present) do something similar.

You can also use command builders to make the commands slightly more automatically. See https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx for more on that.
__________________
Rod

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Add/Update/Delete Database records MANUALLY jn148 BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 December 14th, 2008 10:18 AM
update dataadapter karenai Visual Basic 2005 Basics 0 February 9th, 2008 10:46 PM
Datagrid.update() and DataAdapter.Update aarunlal ASP.NET 2.0 Professional 2 February 23rd, 2006 11:41 PM
Inserting records into DB using DataAdapter favor ADO.NET 4 June 16th, 2005 03:29 AM
How to Add/Delete/Update multiple records in DB? mmwaikar ADO.NET 1 September 20th, 2003 12:41 PM



All times are GMT -4. The time now is 11:34 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.