You use Microsoft .NET Framework 4 to develop an application that connects to a Microsoft SQL
Server 200B database. You populate a SqlDataAdapter by using the following code. (Line numbers
are included for reference only.)
01 SqlDataAdapter dataAdapterl = new SqlDataAdapter
(“SELECT * FROM [BlogEntries]
ORDER BY CreationDote”, connection);
02 cmdBuilder = nev SqlCormnandBuilder(dataAdapterl);
03 dataAdapterl.Fill(BlogEntryDataSet, “BlogEntries”); 04
05 connection.Close()
You need to update the blog owner for all BlogEntry records.
Which code segment should you insert at line 04?
A.
foreach(DataRou row in BlogEntryDataSet.Tables [“BlogEntries”].ROWS)
{
row.Item[“BlogOwner””] = “New Owner”;
}
dataAdapterl.Update(BlogEntryDataSet, “BlogEntries”);
B.
foreach(DataRow row in BlogEntryDataSet.Tables
[“BlogEntries”].Rows) (
tow.Item[“Blog0wner””] = “New Owner”;
}
dataAdapterl.Fill(BlogEntryDataSet, “BlogEntries”);
C.
SqlDataAdapter dataAdapter2 = new SqlDataAdapter
(“UPDATE [BlogEntries] SET [BlogOwner = ‘New ‘Owner’ 3”,
connection);
dataAdapter2-Update(BlogEntryDataSet, “BlogEntries”);
D.
SqlDataAdapter dataAdapter2 = new SqlDataAdapter
(dataAdapterl.UpdateCommand) ;
dataAdapter2.Fill(BlogEntryDataSet, “BlogEntries”);
Explanation:
SqlDataAdapter.Update() – Calls the respective INSERT, UPDATE, or DELETE statements for each
inserted, updated, or deleted row in the System.Data.DataSet with the specified
System.Data.DataTable name.
(http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommandbuilder.aspx)