1.
You work as an application developer at Contoso.com. You use Microsoft .NET Framework 3.5 and Microsoft ADO.NET to develop an application that will connect to the Microsoft SQL Server 2005 database. The application caches refer to tables by using a Local Database Cache class. You have completed the following code segment. (Line numbers are for reference only.) 01 public partial class LocalDataCacheProvider 02 { 03 private void InitializeConnection(string connectionString) 04 { 05 this.Connection = new System.Data.SqlClient.SqlConnection(connectionString); 06 } 07 private void InitializeNewAnchorCommand() 08 { 09 10 } 11 } You want to make sure that the LocalDataCacheProvider class handles all database communication. What should you do?
2.
You work as an application developer at Contoso.com. You use Microsoft .NET Framework 3.5 and Microsoft ADO.NET to develop an application that will connect to the Microsoft SQL Server 2005 database. You want to define a class named Order that can participate within a transaction. What should you do?
3.
You work as an application developer at Contoso.com. You use Microsoft .NET Framework 3.5 and Microsoft ADO.NET to develop an application that will connect to the Microsoft SQL Server 2005 database. The application has two DataTable objects that reference the Customers and Orders tables in the database. Your application contains the following code. (Line numbers are for reference only.) 01 DataSet custOrderDS = new DataSet(); 02 custOrderDS.EnforceConstraints = true; 03 ForeignKeyConstraint custOrderFK = new ForeignKeyConstraint("CustOrderFK", 04 custOrderDS.Tables["Customers"].Columns["CustomerID"], 05 custOrderDS.Tables["Orders"].Columns["CustomerID"]); 06 07 custOrderDS.Tables["Orders"].Constraints.Add(custOrderFK); You want to make sure that an exception is thrown when you attempt to delete Customer records that have related Order records. What should you do?
4.
You work as an application developer at Contoso.com. You use Microsoft .NET Framework 3.5 and Microsoft ADO.NET to develop an application that will connect to the Microsoft SQL Server 2005 database. The Microsoft SQL Server 2005 database also contains a tblOrderDetails table. You want to create an exception handler for the application. A DDL statement was used to create the tblOrderDetails table. The DDL statement was as follows: 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)) The application uses Microsoft OLE DB Provider as the data provider. You have changed the data provider to Microsoft SqlClient. Lately now, the application throws errors while executing parameterized queries. You want to make sure that the users are notified when an update to the tblOrderDetails table causes a violation of any constraint. What should you do?
5.
You work as an application developer at Contoso.com. You use Microsoft .NET Framework 3.5 and Microsoft ADO.NET to develop an application that will connect to the Microsoft SQL Server 2005 database. You have completed the following code segment in the exception handler of the application. (Line numbers are 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 make an insertion on line 07 so that the original severity level of the error is included in the error message for each SQL error that occurs. What should you do?
6.
You work as an application developer at Contoso.com. You use Microsoft .NET Framework 3.5 and Microsoft ADO.NET to develop an application. The application of Contoso.com contains two entities named Customer and Order. Customer has a navigable property named Orders, which returns a collection of Order entity instances. Your application contains the following code. ContosoEntities context = new ContosoEntities(); ObjectQuery query; You need to make sure that each time a Customer entity instance is queried the related Order entity instances are retrieved. What should you do?
7.
You work as an application developer at Contoso.com. You use Microsoft .NET Framework 3.5 and Microsoft ADO.NET to develop an application that will connect to the Microsoft SQL Server 2005 database. Your application contains the following code. (Line numbers are for reference only.) 01 private void Update (SqlCommand cmdA, SqlCommand cmdB) 02 { 03 using (TransactionScope scope = new TransactionScope()) 04 { 05 06 } 07 } You want to run the SqlCommand objects named cmdA and cmdB within a single distributed transaction. What should you do?
8.
You work as an application developer at Contoso.com. You use Microsoft .NET Framework 3.5 and Microsoft ADO.NET to develop an application that will connect to the Microsoft SQL Server 2005 database. You have completed the following code segment. (Line numbers are for reference only.) 01 String myConnString = "User ID = ; 02 password = ; 03 Initial Catalog = pubs; 04 Data Source = myServer"; 05 SqlConnection myConnection = new SqlConnection(myConnString); 06 SqlCommand myCommand = new SqlCommand(); 07 DbDataReader myReader; 08 myCommand.CommandType = CommandType.Text; 09 myCommand.Connection = myConnection; 10 myCommand.CommandText = "Select * from Table1; 11 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. What should you do?
9.
You work as an application developer at Contoso.com. You use Microsoft .NET Framework 3.5 and Microsoft ADO.NET to develop an application that will connect to the Microsoft SQL Server 2005 database. You have completed the following code segment. (Line numbers are for reference only.) DataTable tbl = new DataTable(); tbl.Columns.Add("Price", typeof(double)); //Other columns added //Fill data You need to retrieve the maximum value in the Price column of the tbl DataTable. What should you do?
10.
You work as an application developer at Contoso.com. You use Microsoft .NET Framework 3.5 and Microsoft ADO.NET to develop an application. You have completed the following conceptual schema definition for the entity data model. You want to retrieve all the TaxNo property values for the Employee entity instance that has the EmployeeID property value as 1. What should you do?