[ Pobierz całość w formacie PDF ]
C: The command object has no ToString method.
D: The ExecuteReader method returns a DataReader object that can iterate through a result set in a forward-
only, read-only manner without involving a DataAdapter.
QUESTION NO: 51
Leading the way in IT testing and certification tools, www.testking.com
- 46 -
070 - 316
You develop a Windows-based application that creates XML output from a DataSet object. The XML
output is created by using the DataSet.WriteXml method and then is sent to another application. The
second application requires the output to appear in the following format:
You need to write code to specify the format for the XML output. Which code segment should you
use?
A. ds.WriteXml(dataFile,
XmlWriteMode.WriteSchema);
B. ds.WriteXml(dataFile,
XmlWriteMode.IgnoreSchema);
C. foreach (DataColumn dc in ds.Tables[ employee ].Columns) {
dc.ColumnMapping = MappingType.Attribute;
}
D. foreach (DataColumn dc in ds.Tables[ employee ].Columns) {
dc.ColumnMapping = MappingType.Element;
}
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 [C#]
NET Framework Class Library. DataSet.WriteXml Method [C#]
QUESTION NO: 52
You develop a Windows-based application called TestKingApplication by using Visual Studio .NET.
TestKingApplication receives XML data files from various external suppliers. An XML Schema file
defines the format and the data types for the XML data files.
TestKingApplication must parse the incoming XML data files to ensure that they conform to the
schema.
What should you do?
A. Implement a DataSet object and code an event handler to process its events.
B. Implement a DataSet object and set its Enforce Constraints property to True.
C. Implement an XmlValidatingReader object and code an event handler to process its events.
D. Implement an XmlValidatingReader object and examine its ReadState property after reading the
XML data file.
Answer: C
Leading the way in IT testing and certification tools, www.testking.com
- 47 -
070 - 316
Explanation: The XmlValidatingReader class, an implementation of the XmlReader class, provides support
for XML validation. The ValidationEventHandler event is used to set an event handler for receiving
information about schema validation errors.
Reference:
.NET Framework Developer's Guide, Validation of XML with XmlValidatingReader
.NET Framework Developer's Guide, XmlValidatingReader Validation Event Handler Callback [C#]
QUESTION NO: 53
You develop a Windows-based application that interacts with a Microsoft SQL Server database. The
application inserts new rows into the database by calling the following stored procedure. (Line
numbers are included for reference only)
01 ALTER PROCEDURE dbo.sp_UpdateTestKingPrice
02 (
03 @category int,
04 @totalprice money OUTPUT
05 )
06 AS
07 SET NOCOUNT ON
08 UPDATE Products SET UnitPrice = UnitPrice * 1.1
WHERE CategoryID = @category
09 SELECT @totalprice = sum(UnitPrice) FROM Products
10 SELECT ProductName FROM Products
WHERE CategoryID = @category
11 RETURN @Totalprice
You application uses the ExecuteReader method of the SqlCommand object to call the stored
procedure and create a SqlDataReader object. After the stored procedure runts, your code must
examine the SqlDataReader.RecordsAffected property to verify that the correct number of records is
successfully updated.
However, when you execute the stored procedure, the SqlDataReader.RecordsAffected property
always returns 1. How should you correct this problem?
A. Change line 7 to
SET ROWCOUNT 0
B. Change line 7 to
SET NOCOUNT OFF
C. Change line 11 to
RETURN 0
D. Change line 11 to
RETURN @category
Answer: B
Leading the way in IT testing and certification tools, www.testking.com
- 48 -
070 - 316
Explanation: SqlDataReader.RecordsAffected Property gets the number of rows changed, inserted, or
deleted by execution of the Transact-SQL statement.
The Transact-SQL SET NOCOUNT command stops the message indicating the number of rows affected by
a Transact-SQL statement from being returned as part of the results. When SET NOCOUNT is ON, the
count (indicating the number of rows affected by a Transact-SQL statement) is not returned. When SET
NOCOUNT is OFF, the count is returned.
Reference:
SQL Server Books Online, SET NOCOUNT
.NET Framework Class Library, SqlDataReader.RecordsAffected Property [Visual Basic]
Incorrect Answers
A: The SET NOCOUNT 0 is incorrect. We should use OFF instead of =.
C, D: We cannot change the functionality of the stored procedure by changing the RETURN statement.
Furthermore, returning = or the value of @Category value does not achieve the desired result.
QUESTION NO: 54
You use Visual Studio .NET to develop a Microsoft Windows-based application. Your application
contains a form named CustomerForm, which includes the following design-time controls:
" SQLConnection object named TestKingConnection
" SQLDataAdapter object named TestKingDataAdapter
" DataSet object named CustomerDataSet
" Five TextBox controls to hold the values exposed by CustomerDataSet
" Button control named saveButton
At design time you set the DataBindings properties of each TextBox control to the appropriate column
in the DataTable object of CustomerDataSet.
When the application runs, users must be able to edit the information displayed in the text boxes. All
user changes must be saved to the appropriate database when saveButton is executed. The event
handler for saveButton includes the following code segment:
NorthwindDataAdapter.Update(CustomerDataSet);
[ Pobierz całość w formacie PDF ]