PrepAway - Latest Free Exam Questions & Answers

Which code segment should you insert at line 04?

You use Microsoft .NET Framework 4.0 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 dataAdapter1 = new SqlDataAdapter(“SELECT * FROM [BlogEntries] ORDER BY CreationDate, connection);
02 cmdBuilder = new SqlCommandBuilder(dataAdapter1);
03 dataAdapter1.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?

PrepAway - Latest Free Exam Questions & Answers

A.
foreach(DataRow row in BlogEntryDataSet.Tables[“BlogEntries”].Rows)
{
row.Item[“BlogOwner””] = �New Owner�;
}
dataAdapter1.Update(BlogEntryDataSet, �BlogEntries�);

B.
foreach(DataRow row in BlogEntryDataSet.Tables[“BlogEntries”].Rows)
{
row.Item[“BlogOwner””] = �New Owner�;
}
dataAdapter1.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)


Leave a Reply