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. Contoso.com has a DataTable object that resides in a database. You application load customer records into the DataTable object that is updated by the users of the application. The updated records may contain errors. You want to make sure that the data in the updated records is validated before it is saved to the database. 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 have completed the following code segment. (Line numbers are for reference only.) 01 SqlConnection sqlconn
02 ...
03 SqlDataAdapter ordAdp = new SqlDataAdapter(
04 SELECT OrderID, CustomerID, OrderDate, Qty, UnitPrice,
05 Discount FROM Sales.OrderDetail, sqlconn);
06 DataSet order_ds = new DataSet();
07 DataTable order_dt = order_ds.Tables.Add("Orders");
08 ordAdpt.Fill(order_dt);
09 order_dt.Rows[0].BeginEdit();
10 // The code here will insert, update and delete rows
11 order_dt.Rows[0].EndEdit();
12
13 order_dt.AcceptChanges();
You want to validate that every row that has the Qty column value is set to zero before you commit any changes. 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 database has a table named Customers. The table is frequently updated by the employees at Contoso.com. Your application contains the following code. (Line numbers are for reference only.)
01 SqlDataAdapter adapter = new SqlDataAdapter(SELECT CustomerID, CompanyName, +
02 LastUpdated +
03 FROM Customers ORDER BY CustomerID, connection);
04 adapter.UpdateCommand = new SqlCommand(
05 UPDATE Customers Set CompanyName = @CompanyName +
06 WHERE CustomerID = @CustomerID AND LastUpdated = @LastUpdated, connection);
07 adapter.UpdateCommand.Parameters.Add(@CustomerID, SqlDbType.Int, 0, CustomerID);
08 adapter.UpdateCommand.Parameters.Add(@CompanyName, SqlDbType.NVarChar, 30,  +
09 CompanyName);
10 SqlParameter parameter = adapter.UpdateCommand.Parameters.Add(
11 @LastUpdated, SqlDbType.Timestamp, 0, LastUpdated);
12 parameter.SourceVersion = DataRowVersion.Original;
You only want the application to update records without optimistic concurrency violations. 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 application has an untyped DataTable object named Users that has a DataColumn named Level. For future plan, you want to create a ColumnChanging event handler for the Users object.You want to make sure that when the existing data is modified, any value in the Age DataColumn that is greater than 100 is set to DBNull. 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 also created a DataSet named Data that has two related tables named Customers and Orders. You have written 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.Data.Orders);
04 this.custTblAdap.Fill(this.Data.Customers);
05 }
06 private void custBindNavSaveItem_Click(object sender, EventArgs e)
07 {
08
09 }
Customers and Orders are regularly updated and you need to make sure that the application commits all the updates to the two tables before it saves the data to the database. 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 that will connect to the Microsoft SQL Server 2005 database. You have completed the following LINQ query for the application. var qry = from o in ordersQuery
where (string)o[TrackCode] == TK09-L20B
select new
{
OrderID = o.Field(OrderID),
OrderDate = o.Field(OrderDate)
};
The TrackCode field in the DataRow is nullable. You want to make sure that an exception does not occur if the TrackCode field has a null value. 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. The application of Contoso.com uses a database that has a Products table and an Inventory table. Furthermore, the application coordinates updates between the records in the Products table and Inventory table by loading a DataSet class named DataSet. Your application contains the following code.
DataColumn parentColumn = DataSet.Tables[Products].Columns[ProdID];
DataColumn childColumn = DataSet.Tables[Inventory].Columns[ProdID];
You need to make sure that the ProdID value has the following characteristics after changing the Products table:
1. The ProdID value is unique.
2. The records in the Inventory table are updated with the new ProdID value.
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. The Microsoft SQL Server 2005 database contains a database named DB1. The DB1 database stores data on two SQL Server 2005 servers named DB01 and DB02. You want to make sure that the application caches the data by configuring the SqlDependency object. 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 also created the following code segment:
DataTable tbl = new DataTable();
DataColumn colId = tbl.Columns.Add(ID, typeof(int)); colId.AutoIncrement = true;
tbl.Constraints.Add(Pkey, colId, true);
DataColumn colProd = tbl.Columns.Add(Product, typeof(string)); colCtry.DefaultValue = SKU;
tbl.Columns.Add(Name, typeof(string));
You want to create a new row in the tbl DataTable with the following characteristics:
1. The ID column is set to an auto-incremented value.
2. The Product column is set to the default value.
3. The Name column is set to the value New Product. 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 code segment. (Line numbers are for reference only.)
01 private void Init()
02 {
03 SyncConflictResolver scr = new SyncConflictResolver();
04 scr.ClientUpdateServerUpdateAction = ResolveAction.FireEvent;
05 SqlCeClientSyncProvider csp = new SqlCeClientSyncProvider();
06
07 }
You need to make sure that the application handles synchronization conflicts when data is updated in the database of the application. What should you do?