PrepAway - Latest Free Exam Questions & Answers

Which code segment should you insert at line 04?

You use Microsoft .NET Framework 4 to develop an application that connects to a Microsoft SQL
Server 2008 database You populate a SqlDataAdapter by using the following code. (Line numbers are
included for reference only.)
01 Dim dataAdapterl As SqlDataAdapter = New SqlDataAdapter(
“SELECT * FROM [BlogEntries] ” &_
“ORDER BY CreationDate”, connection)

02 cindBuilder = New SqlCoittnandBuilder (dataAdapterl)
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.
Dim dataAdapter2 As SqlDataAdapter = New SqlDataAdapter(
dataAdapterl.UpdateCommand)
dataAdapter2.Fill(BlogEntryDataSet, “BlogEntries”)

B.
For Each row As DataRow In BlogEntryDataSet.Tables(_
“BlogEntries”).Rows row.Item(“BlogOwner”) = “New Owner” Next
dataAdapterl.Update(BlogEntryDataSet, “BlogEntries”)

C.
For Each row As DataRow In BlogEntryDataSet.Tables(
“BlogEntries”).Rows
row.Item(“BlogOwner”) = “New Owner”
Next
dataAdapterl.Fill(BlogEntryDataSet, “BlogEntries”)

D.
Dim dataAdapter2 As SqlDataAdapter = New SqlDataAdapter(
“UPDATE [BlogEntries] SET [BlogOwner = ‘New ‘Owner’]”,
connection)
dataAdapter2.Update(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