PrepAway - Latest Free Exam Questions & Answers

Author: admin

What should you do to dynamically add the UserCtrl.ascx control between the lblHeader and lblFooter Label cont

You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.
Your application has a user control named UserCtrl.ascx. You write the following code fragment to create a Web page named Default.aspx.
<%@ Page Language="VB" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<html> …
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="lblHeader" runat="server"></asp:Label>
<asp:Label ID="lbFooter" runat="server"></asp:Label>
</div>
</form>
</body>
</html>
You need to dynamically add the UserCtrl.ascx control between the lblHeader and lblFooter Label controls.
What should you do?

What should you do to ensure that when the size of the LineTotal column value is greater than seven characters

You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.
You create a Web page that contains the following two XML fragments. (Line numbers are included for reference only.)
01 <script runat="server">
02
03 </script>
04 <asp:ListView ID="ListView1" runat="server"
05 DataSourceID="SqlDataSource1"
06
07 >
08 <ItemTemplate>
09 <td>
10 <asp:Label ID="LineTotalLabel" runat="server"
11 Text='<%# Eval("LineTotal") %>’ />
12 </td>
13 </ItemTemplate>
The SqlDataSource1 object retrieves the data from a Microsoft SQL Server 2005 database table. The database table has a column named LineTotal.
You need to ensure that when the size of the LineTotal column value is greater than seven characters, the column is displayed in red color.
What should you do?

What should you do connect to the Sales database when the user account for the connection is SalesUser?

You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET.

The application is used to retrieve records from a database named Sales. The database resides on a Microsoft SQL Server 2005 server named ProdServer.
The application connects to the database by using an instance of the SqlConnection class that has the following connection string.

"Data Source=ProdServer;UID=SalesUser;PWD=Pa$$w0rd;"

When the application calls the Open method of the SqlConnection object, the following exception is thrown:

"Cannot open user default database. Login failed. Login failed for user ‘SalesUser’".

The default database for SalesUser is Sales.

You need to ensure that you can connect to the Sales database when the user account for the connection is SalesUser.

What should you do?

What should you do to calculate the tax amount for each order invoice in the Invoice DataTable object?

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 uses a strongly typed DataTable class named Invoice to process order invoices.
The application contains third-party components and the Invoice DataTable class that cannot be recompiled.
The application processes the order invoices by passing the Invoice DataTable object to these third-party components.

You need to calculate the tax amount for each order invoice in the Invoice DataTable object.

What should you do?

What should you do to successfully delete the data from the tblCustomers table?

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 two DDL statements.

CREATE TABLE tblCustomers(
CustID INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
CompanyName VARCHAR(50) NOT NULL,
ContactName VARCHAR(100) NOT NULL)
GO

CREATE TABLE tblCustomerOrders(
OrderID INT IDENTITY(1,1) NOT NULL,
CustID INT NOT NULL FOREIGN KEY REFERENCES tblCustomers(CustID),
OrderDate DateTime NOT NULL)

When a user attempts to delete the data from the tblCustomers table during execution, the application throws a SqlException exception.
The application was designed without any DataRelation objects.

You need to successfully delete the data from the tblCustomers table.

What should you do?

What should you do to ensure that the application executes the parameterized queries?

You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET.

The application uses Microsoft OLE DB Provider as the data provider. You change the data provider to Microsoft SqlClient. The application throws errors while executing parameterized queries.

You need to ensure that the application executes the parameterized queries.

What should you do?

What should you do to display the tables simultaneously by using a single SqlConnection object?

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 database contains two tables that are displayed in two different GridView controls. The tables are displayed by using two SqlConnection objects.
You need to display the tables simultaneously by using a single SqlConnection object.

What should you do?

What should you do to ensure that all valid records are retrieved even if invalid records are present?

You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET.

You write the following code segment. (Line numbers are included for reference only.)

01 private void GetRecords(SqlDataAdapter da, DataTable table) {
02
03 try {
04 da.Fill(table);
05 }
06 catch (SqlException exp) {
07
08 }
09 finally {
10
11 }
12 }

The da.SelectCommand.CommandText property is set to a stored procedure. The stored procedure declares a variable named @msg.

For each record that contains a bad shipping address, the stored procedure performs the following tasks:

It sets @msg with the id of the record.
It raises an error for the record.

The error raised is as shown in the following text: RaiseError(@msg, 10, 1)

You need to ensure that all valid records are retrieved even if invalid records are present. You also need to ensure that a list item is added to the lstResults list box for each invalid record.

What should you do?