You create a Microsoft ASP.NET application by using the Microsoft .NET Framework
version 3.5. The application consumes a Microsoft Windows Communication Foundation
(WCF) service.The WCF service exposes the following method.
[WebInvoke]
string UpdateCustomerDetails(string custID);
The application hosts the WCF service by using the following code segment.
WebServiceHost host = new WebServiceHost(typeof(CService), new Uri("http://win/"));
ServiceEndpoint ep = host.AddServiceEndpoint(typeof(ICService), new WebHttpBinding(),
"");
You need to invoke the UpdateCustomerDetails method. 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 create a
DataSet named northwind. The northwind DataSet contains two related tables named
Customers and Orders.You write the following code segment. (Line numbers are included
for reference only.)
01 private void Page_Load(object sender, EventArgs e)
02 {
03 this.ordTblAdap.Fill(this.northwind.Orders);
04 this.custTblAdap.Fill(this.northwind.Customers);
05 }
06 private void custBindNavSaveItem_Click(object sender, EventArgs e)
07 {
08
09 }
The two tables in the northwind DataSet are updated frequently.
You need to ensure that the application commits all the updates to the two tables before it
saves the data to the database.Which code segment should you insert at line 08?
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 the following stored procedure. CREATE PROCEDURE
[dbo].[UpdateShippers]
@CountryCode NVarchar(10)
,@NewRateCode int
AS BEGIN
Update dbo.Shippers
SET RateCode = @NewRateCode Where CountryCode = @CountryCode RETURN
@@ROWCOUNT
END
You write the following code segment. (Line numbers are included for reference only.)
01 using (SqlConnection connection = new
SqlConnection(connectionString))
02 {
03 connection.Open();
04 SqlCommand command = new
SqlCommand("UpdateShippers", connection);
05
06 command.ExecuteNonQuery();
07 }
You need to ensure that the application can update the Shippers table. Which code 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 connects to a Microsoft SQL Server 2005 database. The
application populates a DataSet object by using a SqlDataAdapter object. You use the
DataSet object to update the Categories database table in the database.You write the
following code segment. (Line numbers are included for reference only.)
01 SqlDataAdapter dataAdpater = new SqlDataAdapter("SELECT CategoryID,
CategoryName FROM Categories", connection);
02 SqlCommandBuilder builder = new SqlCommandBuilder(dataAdpater);
03 DataSet ds = new DataSet();
04 dataAdpater.Fill(ds);
05 foreach (DataRow categoryRow in ds.Tables[0].Rows)
06 {
07 if (string.Compare(categoryRow["CategoryName"].ToString(), searchValue, true) == 0)
08 {
09
10 }
11 }
12 dataAdpater.Update(ds);
You need to remove all the records from the Categories database table that match the value
of the searchValue variable.Which line of code should you insert at line 09?
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 that contains
a table named Customers.Concurrent users update the Customers table frequently.You write
the following code segment. (Line numbers are included for reference only.)
01 SqlDataAdapter adapter = new SqlDataAdapter(
"SELECT CustomerID, CompanyName, LastUpdated" +
" FROM Customers ORDER BY CustomerID", connection);
02 adapter.UpdateCommand = new SqlCommand(
"UPDATE Customers Set CompanyName = @CompanyName"
+ " WHERE CustomerID = @CustomerID AND " +
"LastUpdated = @LastUpdated", connection);
03 adapter.UpdateCommand.Parameters.Add(
"@CustomerID", SqlDbType.Int, 0, "CustomerID");
04 adapter.UpdateCommand.Parameters.Add(
"@CompanyName", SqlDbType.NVarChar, 30,
"CompanyName");
05 SqlParameter parameter =
adapter.UpdateCommand.Parameters.Add(
"@LastUpdated", SqlDbType.Timestamp, 0,
"LastUpdated");
06 parameter.SourceVersion = DataRowVersion.Original;
07
You need to ensure that the application updates only records without optimistic concurrency
violations.What should you do?
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 that contains
the tblOrderDetails table.You plan to create an exception handler for the application.The
tblOrderDetails table has been created by using the following DDL statement. CREATE
TABLE tblOrderDetails(
[OrderID] int NOT NULL FOREIGN KEY REFERENCES
tblCustomerOrders(OrderID),
[ProductID] int NOT NULL,
[Qty] int NOT NULL,
[UnitPrice] float CONSTRAINT ckPositivePrice CHECK (UnitPrice >=0),
[Discount] float CONSTRAINT ckPositiveDiscount CHECK (Discount >=0))
You need to ensure that the users are notified when an update to the tblOrderDetails table
causes a violation of any constraint. What should you do?
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 in the exception handler of the application. (Line numbers are
included for reference only.)
01 private string ShowSQLErrors(SqlException ex){
02 StringBuilder sb = new StringBuilder();
03 foreach (SqlError err in ex.Errors) {
04 sb.Append("Message: ");
05 sb.Append(err.Number.ToString());
06 sb.Append(", Level: ");
07
08 sb.Append(", State: ");
09 sb.Append(err.State.ToString());
10 sb.Append(", Source: ");
11 sb.AppendLine(err.Source.ToString());
12 sb.AppendLine(err.Message.ToString());
13 sb.AppendLine();
14 }
15 return sb.ToString();
16 }
You need to ensure that the original severity level of the error is included in the error
message for each SQL error that occurs.Which line of code should you insert at line 07?
You create a Microsoft ASP.NET application by using the Microsoft .NET Framework
version 3.5. The application contains two Web pages named OrderDetails.aspx and
OrderError.htm.If the application throws unhandled errors in the OrderDetails.aspx Web
page, a stack trace is displayed to remote users.You need to ensure that the OrderError.htm
Web page is displayed for unhandled errors only in the OrderDetails.aspx Web page. What
should you do?
You are creating a multiple-document interface (MDI) application by using the .NET
Framework 3.5.You configure the frmParent form to be an MDI parent.You write the
following code segment. (Line numbers are included for reference only.)
01 Form frmChild = new Form();
02 Form frmParent = this;
03
You need to associate and display the frmChild form and the frmParent form. Which code
segment should you add at line 03?
You are creating aWindows Forms application for a courier company by using the .NET
Framework 3.5.You create a form that allows customers to track the progress of their
shipments. The form contains the following elements:
A text box named txtTN that allows users to enter a tracking number
An ErrorProvider control named ErrorProvider1 that informs users of an invalid
tracking number
A function named ValidTrackingNumber that validates tracking numbers
You need to ensure that the txtTN text box is validated. Which code segment should you
use?