What should you do?
You create Microsoft Windows-based applications. You create a component that calls an existing function. The design for the function specifies that it might throw an application-specific exception named InvalidChecksumException, which inherits from System.ApplicationException. The InvalidChecksumException exception is an error that can be handled. But the component cannot handle any other type of error. The component does not have any additional information that can be added to other types of errors. You need to design the component to correctly handle exceptions. You also need to ensure that the exception-handling strategy does not affect performance.
What should you do?
What should you do?
A Windows Forms application loads an XmlDocument from a file named books.xml. You need to validate the XML against a schema that is contained in the books.xsd file when the XML loads.
What should you do?
Which code segment should you use?
You are creating a Windows Forms application. The application uses a SqlCommand object named cmd. The cmd object executes the following stored procedure.
CREATE PROCEDURE GetPhoneList
AS
BEGIN
SELECT CompanyName, Phone FROM Customers
SELECT CompanyName, Phone FROM Suppliers
END
You need to add all returned rows to the ListBox control named lstPhones.
Which code segment should you use?
Which code segment should you use?
You are creating a Windows Forms application that includes the database
helper methods UpdateOrder and UpdateAccount. Each method wraps code that connects to a Microsoft SQL Server 2005 database, executes a Transact-SQL statement, and then disconnects from the database. You must ensure that changes to the database that result from the UpdateAccount method are committed only if the UpdateOrder method succeeds. You need to execute the UpdateAccount method and the UpdateOrder method.
Which code segment should you use?
What should you do?
A method in your Windows Forms application executes a stored procedure in a Microsoft SQL Server 2005 database, and then executes a second stored procedure in a second SQL Server 2005 database. You need to ensure that the call to the first stored procedure writes changes only if the call to the second stored procedure succeeds. Installation requirements prohibit you from introducing new components that use the COM+ hosting model.
What should you do?
What should you do?
You are creating a Windows Forms application to retrieve and modify data. Depending on the installation, the data source can be a Microsoft Access database or a Microsoft SQL Server 2000 or later database. You need to ensure that your application accesses data by automatically using the data provider that is optimized for the data source.
What should you do?
What should you do?
You are creating a Windows Forms application that implements a master/detail form by using two DataGridView controls. You populate a dataset with a master table and a details table. You set the DataSource property of the master DataGridView control to the dataset. You set the DataMember property to the name of the master table. You also set the DataSource property of the details DataGridView control to the dataset. You need to ensure that the details DataGridView control displays only the child rows of the selected master row.
What should you do?
Which code segment should you add at line 03?
You are creating a Windows Forms application. The application loads a data table named dt from a database and modifies each value in the data table. You add the following code.
(Line numbers are included for reference only.)
01 foreach (DataRow row in dt.Rows) {
02 foreach (DataColumn col in dt.Columns) {
04 Trace.WriteLine(str);
05 }
06 }
You need to format the string named str to show the value of the column at the time the data is loaded and the current value in the column.
Which code segment should you add at line 03?
Which code segment should you use?
You are creating a Windows Forms application. Initialization code loads a DataSet object named ds that includes a table named Users. The Users table includes a column named IsManager. You need to bind the IsManager column to the Checked property of a check box named chkIsManager.
Which code segment should you use?
Which code segment should you use?
A Windows Forms application contains the following code segment.
string SQL = @”SELECT OrderID, ProductID, UnitPrice, Quantity FROM [Order Details]”;
SqlDataAdapter da = new SqlDataAdapter(SQL, connStr);
DataTable dt = new DataTable();
da.Fill(dt);
You need to add a new column to the data table named ItemSubtotal. The ItemSubtotal column must contain the value of the UnitPrice column multiplied by the value of the Quantity column.
Which code segment should you use?