segment should you insert at line 05?
You create an application by using the Microsoft .NET Framework 3.5 and Microsoft
ADO.NET.The application contains a DataSet object named OrderDS that has the Order and
OrderDetail tables as shown in the following exhibit.
You write the following code segment. (Line numbers are included for reference only.)
01 private void GetOrders(SqlDataConnection cn) {
02 SqlCommand cmd = cn.CreateCommand();
03 cmd.CommandText = “Select * from [Order];
Select * from [OrderDetail];”;
04 SqlDataAdapter da = new SqlDataAdapter(cmd);
05
06 }
You need to ensure that the Order and the OrderDetail tables are populated. Which code
segment should you insert at line 05?
Which code segment should you use?
You are creating a Windows Forms application for inventory management by using the
.NET Framework 3.5.The application provides a form that allows users to maintain stock
balances. The form has the following features:
A dataset named dsStockBalance to store the stock information
A business component named scInventory
The scInventory component provides a method named Save.You need to ensure that only
the modified stock balances of dsStockBalance are passed to the scInventory.Save
method.Which code segment should you use?
should you use?
You create a Microsoft ASP.NET application by using the Microsoft .NET Framework
version 3.5.You create a composite custom control named MyControl.You need to add an
instance of the OrderFormData control to the MyControl control. Which code segment
should you use?
Which code segment should you insert at line 16?
You create an application by using the Microsoft .NET Framework 3.5 and Microsoft
ADO.NET. The application uses Microsoft SQL Server 2005.You write the following code
segment. (Line numbers are included for reference only.)
01 String myConnString = “User
02 ID=<username>;password=<strong password>;Initial
03 Catalog=pubs;Data Source=myServer”;
04 SqlConnection myConnection = new
05 SqlConnection(myConnString);
06 SqlCommand myCommand = new SqlCommand();
07 DbDataReader myReader;
08 myCommand.CommandType =
09 CommandType.Text;
10 myCommand.Connection = myConnection;
11 myCommand.CommandText = “Select * from Table1; Select * from Table2;”;
12 int RecordCount = 0;
13 try
14 {
15 myConnection.Open();
16
17 }
18 catch (Exception ex)
19 {
20 }
21 finally
22 {
23 myConnection.Close();
24 }
You need to compute the total number of records processed by the Select queries in the
RecordCount variable.Which code segment should you insert at line 16?
segment should you insert at line 11?
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?
Which code segment should you insert at line 03?
You create an application by using the Microsoft .NET Framework 3.5 and Microsoft
ADO.NET.The application contains a DataSet object named orderDS. The object contains a
table named Order as shown in the following exhibit.
The application uses a SqlDataAdapter object named daOrder to populate the Order table.
You write the following code segment. (Line numbers are included for reference only.)
01 private void FillOrderTable(int pageIndex) {
02 int pageSize = 5;
03
04 }
You need to fill the Order table with the next set of 5 records for each increase in the
pageIndex value.Which code segment should you insert at line 03?
Which code segment should you use?
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?
Which code fragment should you add on Line 07?
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?
Which code segment should you insert at line 04?
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.
<asp:Repeater ID=”rptData” runat=”server”
DataSourceID=”SqlDataSource1″ ItemDataBound=”rptData_ItemDataBound”>
<ItemTemplate>
<asp:Label ID=”lblQuantity” runat=”server” Text='<%# Eval(“QuantityOnHand”) %>’ />
</ItemTemplate>
</asp:Repeater>
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?
Which code segment should you use?
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?