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 uses a strongly typed DataTable named Customers that stores information about customers. The application has an import feature that returns a list of the customers which is stored in an untyped DataTable named NewCustomers. The column order and column types of NewCustomers are same as that of the Customers. You want to copy the information from NewCustomers to a typed DataTable named Cust. 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. The application of Contoso.com contains a DataTable object named OrderDetail that has the following columns: ID, OrderID, ProdID, Qty and Total. OrderDetail is populated with data provided by a business associate. Some of the records contain a null value in the Total field and 0 in the Qty field. You have written the following code segment. (Line numbers are included for reference only.)
01 DataColumn col = new DataColumn(UnitPrice, typeof(decimal));
02
03 OrderDetailTable.Columns.Add(col);
You want to add a DataColumn named UnitPrice to OrderDetail.
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 a typed DataSet named DSOrders that has two DataTables as seen in the following sequence:
1. 1 Orders
2. 2 Customers
Your application contains the following code. (Line numbers are for reference only.)
DSOrders ds = new DSOrders();
IDataReader rd;
You want to expose the two DataTables as a DataReader stream and to make sure that the Customers DataTable is the first DataTable in the stream. 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 uses a SqlDataAdapter object to populate the DataSet object. The DataSet object is used to update the Categories database table in the database. Your application contains the following code. (Line numbers are
for reference only.)
01 SqlDataAdapter dataAdapter = new SqlDataAdapter(
02 SELECT CategoryID, CategoryName FROM Categories, connection);
03 SqlCommandBuilder builder = new SqlCommandBuilder(dataAdpater);
04 DataSet ds = new DataSet();
05 dataAdpater.Fill(ds);
06 foreach (DataRow categoryRow in ds.Tables[0].Rows)
07 {
08 if (string.Compare(categoryRow["CategoryName"].ToString(),searchValue, true) == 0)
09 {
10
11 }
12 }
13 dataAdapter.Update(ds);
You want to remove all the records from the Categories database table that match the value of the searchValue variable. 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. The application has two DataSets named CustomersDS with a DataTable named Customers and OrdersDS that has a Datatable named Orders. Your application contains the following
code:
CustomersDS dsCust = new CustomersDS();
OrdersDS dsOrd = new OrdersDS();
...
IDataReader rd;
Your application requires that you to expose the Customers and Orders datatables by using a DataReader stream. 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. 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?
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.)
DataTable dt = new DataTable(User);
dt.Columns.Add(ID, typeof(Int32));
dt.Columns.Add(City, typeof(String));
dt.Columns.Add(State, typeof(String));
dt.Rows.Add(1, UK, 297EU);
dt.Rows.Add(2, CA, 33NA);
dt.Rows.Add(3, US, 729NA);
var qry = from s in dt.AsEnumerable()
select s[State];
foreach (string rNum in qry) You need to display only the digits from the State field. 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 two tables named Certs and Exams. The application uses a DataSet object that contains two DataTable objects that reference the Certs and Exams tables. Your application contains the following code.
DataSet CertExamDS= new DataSet();
CertExamDS.EnforceConstraints = true;
DataRelation CertExamRel = new DataRelation(CertExamRel, CertExamDS.Tables[Certs].Columns
[CertID],
CertExamDS.Tables[Exam].Columns[CertID]);
CertExamDS.Relations.Add(CertExamRel);
The Certs table has 300 records that are related to records in the Exam table. You want the application to have
the following character:
1. It throws an exception when you attempt to delete related records.
2. It updates the related records in the Exam table when you update records in the Certs table. 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. The application uses a strongly typed DataTable class named Invoice to process order invoices. The application has a third-party components and the Invoice DataTable class. This cannot be recompiled. The application processes the order invoices. The method that is using is by passing the Invoice DataTable object to the third- party components. You want to calculate the tax amount for each order invoice in the Invoice DataTable object. 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.
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?