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. 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?
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. Your application contains the following code.
string qry = "Select UserNo, UserName from dbo.USERS; select Name, Age from dbo.USER_DATA";
SqlCommand command = new SqlCommand(qry, connection); SqlDataReader reader = command.ExecuteReader();
You want to make sure that the application reads all the rows returned by the code segment.
What should you do?
3.
You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET.
The application uses data from a Microsoft SQL Sever 2005 database table. The table contains a column that is define type (UDT) containing a Point object.
You write the following code segment. (Line numbers are included for reference only.)
01 private List GetPoints(SqlCommand cmd) {
02 List List = new List() ;
03 cmd. Connection.Open() ;
04 SqlDataReader reader " cmd.ExecuteREader();
05
06 while (reader.Read()) {
07
08 list.Add(pt) ;
09 }
10 return list ;
11 }
You need to return a list of Point objects.
What should you do?
4.
You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET.
The application uses data from a Microsoft SQL Sever 2005 database table. A Web page of the application
You write the following code segment. (Line numbers are included for reference only.)
01 private void LoadGrid()
02 {
03 using (SqlCommand command = new SqlCommand())
04 {
05 command. Connection = connection;
06 command. CommandText = "SELECT * FROM Customers";
07 connection. Open () ;
08
09 }
10 }
You need to retrieve the data from the database table and bind the data to the DataSource property of the GridView1
Which code segment should you insert at line 08?
5.
You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET.
2005 database
You write the following code segment. (Line numbers are included for reference only.)
01 private void InsertCoordinates(DataTable dataTable, SqlDataAdapter da) {
02 SqlCommand InsertCmd = new SqlCommand ();
03 InsCmd.Connection = da SelectCommand. Connection;
04 InsCmd. CommandText = "InsertCoordinates";
05 da. InsertCommand = insertCmd;
06 SqlParameter prmCoord = new SqlParameter ();
07 prmCoord.ParameterName = "@coordinate";
08 prmCoord.SourceColumm = "Coordinates";
09
10 InsertCmd. Parameter.Add(prmCoord);
11 da.Update(dataTable);
12 }
You write the following definition.
CREATE PROC [dbo] . [InsertCoordinate]
Coordinate Point
AS
INSERT dbo. RegionCoordinates(Coordinate)
VALUES (@coordinate)
The Coordinate columm in dataTable is a .NET Framework class type.
You need to ensure that the prmCoord parameter accepts
Which code segment should you insert at line 09?
6.
You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET. with Microsoft SQL Server 2005 database.
The application analyzes large amounts of transaction data that are stored in a different data
You write the following code segment. (Line numbers are included for reference only.)
01 using (SqlConnection connection = new
SqlConnection (soureConnectionString))
02 using (SqlConnection connection2 = new
SqlConnection (destinatonConnectionString))
03 using (SqlCommand command = new SqlCommand())
04 {
05 connection.Open();
06 connection2.Open();
07 using (SqlDataReader reader = command. ExecuteReader())
08 {
09 using (SqlBulkCopy bulkcopy = new
SqlBulkCopy(connection2)
10 {
11
12 }
13 }
14 }
You need to copy transaction data to the database of application
Which code segment should you insert at line 11?
7.
You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET.
The application reads the following contacts .xml file


Done
Hall



Simon
Rapier



Shu
Ito



You write the following code segment. (Line numbers are included for reference only.)
01 XDocument loaded = XDocument Load(@"C:\ contacts.xml");
02
03 foreach (string name in q)
04 Console.WriteLine("{0}", name);
You need to ensure that the application outputs only the names Simon Rapier and Shu Ito
Which code segment should you insert at line 02?
8.
You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET.
The application contrains a DataSet object that has a table. The DataSet object is as shown in the following
You need to ensure that the application meets the following requirements without creating another table
The DataSet can be extended by using the designer.
The application displays all product records.
The product records can be filtered by ProductID.
What should you do?
9.
The application has a DataTable. The object has the following columm
ID
OrderID
ProductID
Quantity
LineTotal
The OrderDetailTable object is populated with data provided by a business partner. Some of the record
field and 0 in the Quantity field.
You write the following code segment. (Line numbers are included for reference only.)
01 DataColumm col = new DataColumm("UnitPrice", typeof(decimal));
02
03 OrderDetailTable. Columms.Add(col);
You need to add DataColumm named UnitPrice to OrderDetailTable object.
Which line of code should you insert at line 02?
10.
You write the following code segment.
DataTable dt " new DataTable("Customer");
dt.Columns.Add("ID", typeof(Int32));
dt.Columns.Add("State",typeof(String));
dt.Columns.Add("RegionCode" ,typeof(String));
dt. Rows. Add (1, "WA", "MT297EM");
dt. Rows. Add (2, "CA", "MT33SG");
dt. Rows. Add (3, "NY", "MT7322MP");
var query = from c in dt.AsEnumerable()
select c ("RegionCode");
foreach (string rNum in query)
You need to display only the digits from the RegionCode field.
Which line of code should you add?