[ Pobierz całość w formacie PDF ]
G: Regsrv32.exe was used to register components on computers in Visual Basic 6.0, Visual C++ 6.0etc.
Regsrv32 is not used for components that are produces by Visual Studio .NET.
QUESTION .101 You develop an inventory management application for Certkiller. The application uses a
SqlDataReader object to retrieve a product code list from a database. The list is displayed in a (Line numbers
are included for reference only)
01 public void ReadMyData (String ConnectionString)
02 {
03 String query =
Actualtests.com - The Power of Knowing
070-316
04 "SELECT CatID, CatName FROM CertkillerCategories";
05 SqlConnection cnn = new
06 SqlConnection (ConnectionString);
07 SqlCommand cmd = new SqlCommand(query, cnn);
08 SqlDataReader reader;
09 cnn.Open();
10 // Insert new code.
11 cnn.Close();
12 }
To enable your application to access data from the SqlDataReader object, you need to insert additional code on
line 10. Your insertion must minimize the use of database server resources without adversely affecting
application performance. Which code segment should you use?
A. reader = cmd.ExecuteReader();while (reader.Read())
{ListBox1.Items.Add(reader.GetString(1));reader.NextResult();}
B. reader = cmd.ExecuteReader();while (reader.Read()) {ListBox1.Items.Add(reader.GetString(1));}
C. reader = cmd.ExecuteReader();while (reader.Read())
{ListBox1.Items.Add(reader.GetString(1));}reader.Close();
D. reader = cmd.ExecuteReader();while (reader.Read())
{ListBox1.Items.Add(reader.GetString(1));reader.NextResult();}reader.Close();
Answer: C
Explanation: If there is a record available the Read Method advances the DataReader to next record and returns
true. If no records are available it returns false. The while loop adds one list item for each record. Finally we
must close the DataReader with the Close method.
Reference: 70-306/70-316 Training kit, Simple Data Access with the DataReader, Pages 265-266 70-306/70-
316 Training kit, Using Multiple Result Sets, Pages 268-269
Incorrect Answers
A, D: The Next Result method is used to retrieve the next result set. This is used when the Command object
contains multiple SQL statements. Next Result executes the next SQL Statement in the Command object. A
multiple result set is not used to populate a list box.
B: We must always close the DataReader when we are finished with it.
QUESTION .102 You develop a Windows-based application to manage inventory for Certkiller inc. The
application calls a Microsoft SQL Server stored procedure named sp_UpdatePrices.sp_UpdateCKPrices
performs a SQL UPDATE statement that increases prices for selected items
in an inventory table. It returns an output parameter named @totalprice and a result set that contains all of the
records that were updated. @totalprice contains the sum of the prices of all items that were updated. You
implement a SqlCommand object that executes sp_UpdateCKPrices and returns the results to a SqlDataReader
object. The SqlDataReader object gives you access to the data in the result set. Which is displayed in a list box
on your Windows Form. The value of @totalprice must also be displayed in a text box on your Windows Form.
You need to write code that will retrieve this value. Which code segment should you use?
A. while (reader.Read() {TextBox1.Text =com.Parameters["@totalprice"].Value.ToString();}reader.Close();
B. do {TextBox1.Text =com.Parameters["@totalprice"].Value.ToString();}while
(reader.Read());reader.Close();
C. TextBox1.Text =com.Parameters["@totalprice"].Value.ToString();reader.Close();
D. reader.Close();TextBox1.Text =com.Parameters["@totalprice"].Value.ToString();
Answer: C
Actualtests.com - The Power of Knowing
070-316
Explanation: First we retrieve the output parameter from the Dataset. Then we close the SQLDataReader.
Reference: 70-306/70-316 Training kit, Executing Commands, Parameters, Page 260-262
Incorrect Answers
A, B: We only have to retrieve the parameter once, not for each record in the result set. We should not use a
while loop.
D: We must retrieve the output parameter before we close the SQLDataReader.
QUESTION .103 You develop a Windows-based application named CertkillerPayroll. Your application
receives information in the form of an XML data file named data File. This file does not include any schema
information. You need to write code to load the XML data into a DataSet object.
Which code segment should you use?
A. DataSet ds = new DataSet("CKPayrollData");ds.ReadXml(dataFile,XmlReadMode.IgnoreSchema);
B. DataSet ds = new DataSet("CKPayrollData");ds.ReadXml(datafile,XmlReadMode.InferSchema);
C. DataSet ds = new DataSet("CKPayrollData");ds.ReadXml(dataFile,XmlReadMode.ReadSchema);
D. DataSet ds = new DataSet("CKPayrollData");ds.ReadXml(dataFile,XmlReadMode.Fragment);
Answer: B
Explanation: The InferSchema XMLReadMode ignores any inline schema, infers schema from the data and
loads the data.
Reference: .NET Framework Class Library, XmlReadMode Enumeration [C#]
Incorrect Answers
A: The Ignore Schema XMLReadMode ignores any inline schema and reads data into the existing Dataset
schema. However, there exists to schema in this scenario.
C: The Read Schema XMLReadMode reads any inline schema and loads the data.
D: The Ignore Schema XMLReadMode reads XML documents against an instance of SQL Server, but we re
reading data from a file.
QUESTION .104 You develop a Windows-based application to manage business contacts. The application
retrieves a list of contacts from a central database. The list is managed locally in a DataSet object named list
Dataset, and it is displayed in a DataGrid control. You create a procedure that will conduct a search after you
enter a combination of personal name and family name. You application currently includes the following code
segment:
DataView dv = new DataView();int i;dv.Table = listDataSet.Tables(0);dv.Sort = "FamilyName,
PersonalName";DataGrid1.DataSource = dv;
You need to search for a conduct whose personal name is Jack and whose family name is King. Which code
segment should you use?
A. object[] values = {"King", "Jack"};i = dv.Find(values);DataGrid1.CurrentRowIndex = i;
B. object() values = {"King, Jack"};i = dv.Find(values);DataGrid1.CurrentRowIndex = i;
C. object[] values = {"Jack", "King"};i = dv.Find(values);DataGrid1.CurrentRowIndex = i;
D. object[] values = {"Jack, King"};i = dv.Find(values);DataGrid1.CurrentRowIndex = i;
Answer: A
Explanation: We load the search parameters into an array. We use two separate values. The first value is the
FamilyName and the second is PersonalName as it is used in the sort command:dv.Sort = "FamilyName,
PersonalName" The family name is King. The personal name is Jack.
Reference: 70-306/70-316 Training kit, Filtering and Sorting in a DataSet, Page 306
Incorrect Answers
[ Pobierz całość w formacie PDF ]