1.
You are creating a Windows Forms application by using the .NET Framework 3.5. You create a new form in the application. You add a ContextMenuStrip control named ctxMenu to the form.You have a user-defined class named CustomControl.You write the following code segment in the application. (Line numbers are included for reference only.) 01 CustomControl myControl = new CustomControl(); 02 You need to ensure that an instance of CustomControl is displayed on the form as a top- level item of thectxMenu control. Which code segment should you add at line 02?
2.
You are creating a Windows Forms application by using the .NET Framework 3.5. You create a new form in your application. You add a PrintDocument control named pntDoc to the form.To support the print functionality, you write the following code segment in the application. (Line numbers are included for reference only.) 01 pntDoc.BeginPrint += new PrintEventHandler(PrintDoc_BeginPrint); 02 ... 03 bool canPrint = CheckPrintAccessControl(); 04 if (!canPrint) { 05 06 } 07 You need to ensure that the following requirements are met: When the user has no print access, font and file stream initializations are not executed and the print operation is cancelled. Print operations are logged whether or not the user has print access. What should you do?
3.
You are creating a Windows Forms application by using the .NET Framework 3.5. You plan to modify a list of orders within a DataGridView control in the application. You need to ensure that a value is required in the first column of the grid control. Which code segment should you use?
4.
You are creating a Windows Forms application by using the .NET Framework 3.5. You write the following code segment to bind a list of categories to a drop-down list.(Line numbers are included for reference only.) 01 OleDbConnection cnnNorthwind = new OleDbConnection(connectionString); 02 OleDbCommand cmdCategory = new OleDbCommand( "SELECT CategoryID, CategoryName FROM Categories ORDER BY CategoryName", cnnNorthwind); 03 OleDbDataAdapter daCategory = new OleDbDataAdapter(cmdCategory); 04 DataSet dsCategory = new DataSet(); 05 daCategory.Fill(dsCategory); 06 You need to ensure that the drop-down list meets the following requirements: Displays all category names. Uses the category ID as the selected item value. Which code segment should you add at line 06?
5.
You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET. The application connects to a Microsoft SQL Server 2005 database.You write the following code segment. (Line numbers are included for reference only.) 01 using (SqlConnection connection = new SqlConnection(connectionString)) { 02 SqlCommand cmd = new SqlCommand(queryString, connection); 03 connection.Open(); 04 05 while (sdrdr.Read()){ 06 // use the data in the reader 07 } 08 } You need to ensure that the memory is used efficiently when retrieving BLOBs from the database.Which code segment should you insert at line 04?
6.
You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET. The application connects to a Microsoft SQL Server 2005 database. You write the following code segment. string query = "Select EmpNo, EmpName from dbo.Table_1; select Name,Age from dbo.Table_2"; SqlCommand command = new SqlCommand(query, connection); SqlDataReader reader = command.ExecuteReader(); You need to ensure that the application reads all the rows returned by the code segment.Which code segment should you use?
7.
You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You create a Web form and add the following code fragment. The SqlDataSource1 DataSource control retrieves the Quantity column values from a table named Products.You write the following code segment to create the rptData_ItemDataBound event handler. (Line numbers are included for reference only.) 01 protected void rptData_ItemDataBound(object sender, 02 RepeaterItemEventArgs e) 03 { 04 05 if(lbl != null) 06 if(int.Parse(lbl.Text) < 10) 07 lbl.ForeColor = Color.Red; 08 } You need to retrieve a reference to the lblQuantity Label control into a variable named lbl. Which code segment should you insert at line 04?
8.
You are creating a Windows Forms application by using the .NET Framework 3.5. You write the following code segment to update multiple databases on a SQL Server 2008 database. (Line numbers are included for reference only.) 01 string connectionStringCustomer = @"Data Source=CUSTOMER;Integrated Security= SSPI;"; 02 string connectionStringOrders = @"Data Source=ORDER ;Integrated Security= SSPI;"; 03 SqlCommand cmdCustomer = new SqlCommand(); 04 SqlCommand cmdOrders = new SqlCommand(); 05 SqlConnection cnnCustomer = new SqlConnection(connectionStringCustomer); 06 SqlConnection cnnOrders = new SqlConnection(connectionStringOrders); 07 You need to ensure that all database updates are included in a single distributed transaction. Which code fragment should you add on Line 07?
9.
You are creating a Windows Forms application by using the .NET Framework 3.5. You write a code segment to connect to a Microsoft Access database and populate a DataSet.You need to ensure that the application meets the following requirements: It displays all database exceptions. It logs all other exceptions by using the LogExceptionToFile. Which code segment should you use?
10.
You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET. The application connects to a Microsoft SQL Server 2005 database.The application analyzes large amounts of transaction data that are stored in a different database. You write the following code segment. (Line numbers are included for reference only.) 01 using (SqlConnection connection = new SqlConnection(sourceConnectionString)) 02 using (SqlConnection connection2 = new SqlConnection(destinationConnectionString)) 03 using (SqlCommand command = new SqlCommand()) 04 { 05 connection.Open(); 06 connection2.Open(); 07 using (SqlDataReader reader = command.ExecuteReader()) 08 { 09 using (SqlBulkCopy bulkCopy = new SqlBulkCopy(connection2)) 10 { 11 12 } 13 } 14 } You need to copy the transaction data to the database of the application. Which code segment should you insert at line 11?