Answer C

Explanation: We want to produce an attribute list with no tags.

The WriteSchema XmlWriteMode writes the current contents of the DataSet as XML data with the relational structure as inline XML Schema as is required in this scenario.

Reference:

.NET Framework Class Library, MappingType Enumeration

.NET Framework Developer's Guide, Writing a DataSet as XML Data [Visual Basic] NET Framework Class Library. DataSet.WriteXml Method [Visual Basic]

Incorrect Answers

All the other proposed solutions are inadequate since they would produce a tagged output:

<employee>

</employee>

QUESTION NO: 17

You are developing a Windows-based application that logs hours worked by your employees. Your design goals require you to maximize application performance and minimize impact on server resources. You need to implement a SqlCommand object that will send a SQL INSERT action query to a database each time a user makes a new entry.

To create a function named LineltemInser, you write the following code: (Line numbers are included for reference only.)

01 Function LineItemInsert(ByVal empid As Integer, _

02 ByVal projectID As Integer, ByVal hrs As Decimal, _

03 ByVal cnn As SqlConnection) As Integer

04 Dim SQL As String

05 Dim Ret As Integer

06 SQL = "INSERT INTO TimeEntries " & _

07 "(EmpID, ProjectID, Hours) VALUES " & _

08 "(" & empID & projectID & ", " & hrs & ") "

09 Dim cmd As New SqlCommand(SQL, cnn)

11 'Insert new code.

13 End Function

Your code must execute the SQL INSERT action query and verify the number of database records that are affected by the query.

Which code segment should you add on line 11?

Ret = Cmd.ExecuteNonQuery()

cnn.Close()

Return Ret

Ret = cmd.ExecuteScalar()

cnn.Close()

Return Ret

C. Dim reader as SqlDataReader cnn.Open()

reader = cmd.ExecuteReader() cnn.Close()

Return reader.RecordsAffected

D. Dim reader As SqlDataReader cnn.Open()

reader = cmd.ExecuteReader() cnn.Close()

Return reader.GetValue()

Answer: A

Explanation: The SqlCommand.ExecuteNonQuery Method Executes a Transact-SQL statement against the Connection and returns the number of rows affected. This is the most effective solution.

0 0

Post a comment