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. Your application contains the following code. SqlConnection conn;
...
SqlDataAdapter adp = new SqlDataAdapter(
SELECT CertID, CertName FROM Products.Certs, conn); SqlDataAdapter exAdp = new SqlDataAdapter(
SELECT ExamID, CertID, ExamCode FROM Products.Exams, conn); DataSet certExams = new DataSet();
adp.Fill(certExams, Certs);
exAdp.Fill(certExams, Orders);
You want to make sure that the output of the certExams DataSet matches the XML schema. The XML schema has the following code fragment:
271
System Administrator

3612
271
70-210

3957
271
70-215

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 also created a conceptual schema definition for the entity data model which is as follows:







/>


You want to retrieve all the TaxNo property values for the User entity instance that has the UserID property
value as 1.
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. You application has the following objects:
1. A SqlDataReader object named reader
2. A SqlCommand object named cmdRecords
3. A SqlCommand object named cmdUpdate
4. A SqlConnection object named conn
The ConnectionString property of the SqlConnection object is as follows:
Server=DB01;Database=Contoso.com;Integrated Security=SSPI To obtain the cmdRecords object, you should use the reader object. The conn object is shared by the cmdRecords and the cmdUpdate objects. You need to make sure that that for each record in the reader object, the application calls the ExecuteNonQuery method of the cmdUpdate object. 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. 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?
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. Your application contains the following code.
string queryString = Select * from dbo.Users;
SqlCommand command = new SqlCommand(queryString, (SqlConnection)connection)); You want to get the value that is contained in the first column of the first row of the result set returned by the query. 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. You have completed the following code segment. (Line numbers are for reference only.)
01 DataTable dtProducts = new DataTable();
02 dtProducts.Columns.Add(ProductID);
03 dtProducts.Columns.Add(ProductName);
04 dtProducts.Columns.Add(CategoryID);
05 dtProducts.Rows.Add(1, ccie, 1);
06 dtProducts.Rows.Add(2, ccnp, 2);
07 dtProducts.Rows.Add(3, ccsp, 1);
08 dtProducts.Rows.Add(4, ccna, 2);
09 DataTable dtCategories = new DataTable();
10 dtCategories.Columns.Add(CategoryID);
11 dtCategories.Columns.Add(CategoryName);
12 dtCategories.Rows.Add(1, CISCO products);
13 dtCategories.Rows.Add(2, a+);
14 var products = dtProducts.AsEnumerable();
15 var categories = dtCategories.AsEnumerable();
16
17 foreach (var element in result) {
18 Console.WriteLine(element);
19 }
Furthermore, when the DataTables are related, the dtProducts DataTable and the CategoryID column as the dtCategories DataTable have a matching value. You need to make an insertion on line 16 so that the product information and the product category of each product are shown. 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 application adds data to a table named Users that has a primary key column. Your application contains the following code. (Line numbers are for reference only.)
01 void ValidateData(DataTable dt)
02 {
03 dt.Columns.Add(IsValid, typeof(Boolean));
04 foreach (DataRow item in dt.Rows)
05 {
06 //Set IsValid to true or false
07 }
08 }
09 DataTable ChangeData()
10 {
11 SqlDataAdapter adp = new SqlDataAdapter();
12 //Setup SqlDataAdapter to get User data
13 DataTable dtOriginal = new DataTable();
14 adp.FillSchema(dtOriginal, SchemaType.Source); 15 adp.Fill(dtOriginal);
16 //Change User details
17 DataTable dtNew = dtOriginal.GetChanges();
18 ValidateData(dtNew);
19
20 return dtOriginal;
21 }
You need to make sure that the ChangeData method returns a DataTable that includes the value in the IsValid column for each row in Users. 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. You have completed the following code segment. DataTable dt = new DataTable(Strings);
dt = new DataTable();
dt.Columns.Add(Strings);
dt.Rows.Add(A-G);
dt.Rows.Add(H-P);
dt.Rows.Add(Q-Z);
var c = from Strings in dt.AsEnumerable() select Strings[0]; int count = 0; You need to make sure that the value of the count variable is 4. 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 that will connect to the Microsoft SQL Server 2005 database. The application is set up to throws an exception when the SQL Connection object is used. You need to use the exception. What should you do?