PrepAway - Latest Free Exam Questions & Answers

Author: admin

Which code segment should you add?

You create a Microsoft Windowsbased application by using the Microsoft .NET Framework 3.5 andnMicrosoft Synchronization Services for Microsoft ADO.NET. The application uses a Microsoft SQL Server 2005 database.

To synchronize data, the application connects to a table named Leads that contains a column named State.
You write the following code segment.

SqlConnection cn = new SqlConnection("SERVER=myServer;DATABASE=CRMDb;");
SqlSyncAdapterBuilder bldr = new SqlSyncAdapterBuilder(cn);

You need to ensure that the application partitions the data horizontally.

Which code segment should you add?

Which two code segments should you add?

You create an application by using the Microsoft .NET Framework 3.5 and Microsoft Synchronization Services for Microsoft ADO.NET.

The application uses a database that contains two tables named Orders and OrderDetails. A primary key to foreign key relationship exists between these two tables.
You write the following code segment.

SyncTable tableOrders = new SyncTable("Orders");
SyncTable tableOrderDetails = new SyncTable("OrderDetails");
SyncGroup orderGroup = new SyncGroup("Changes");

You need to ensure that the following requirements are met:

Updates are synchronized to both the tables.
Referential integrity is accounted for.

Which two code segments should you add? (Each correct answer presents part of the solution. Choose two.)

Which line of code should you insert at line 06?

You are creating a Microsoft Windows Mobilebased application by using the Microsoft .NET Framework 3.5 and Microsoft Synchronization Services for Microsoft ADO.NET.

You write the following code segment. (Line numbers are included 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 ensure that the application handles synchronization conflicts when data is updated in the database of the application.

Which line of code should you insert at line 06?

Which code segment should replace line 01?

You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET.

The application caches refer to tables by using a Local Database Cache class.
You write the following code segment. (Line numbers are included 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 need to ensure that the LocalDataCacheProvider class handles all database communication.

Which code segment should replace line 01?

Which code segment should you use?

You create a Microsoft Windows Service application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET.

The application uses a Microsoft SQL Server 2005 database named Store.
The Store database stores data in two SQL Server 2005 servers named Server1 and Server2.
You need to ensure that the application caches the data by configuring the SqlDependency object.

Which code segment should you use?

Which code segment should you insert at line 05?

You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET.

You write the following code segment in the application. (Line numbers are included for reference only.)

01 string connString = "server=localhost;database=Store;uid=user;pwd=pass;";
02 SqlConnection conn = new SqlConnection(connString);
03 SqlDependency sqlDep = new SqlDependency();
04 sqlDep.OnChange += new OnChangeEventHandler(sqlDep_OnChange);
05
06 cmd.ExecuteNonQuery();
07 cmd.Connection.Close();

You store order details in a table named Orders in the Store database. You need to ensure that the application receives a notification if an order is inserted or updated in the Orders table.

Which code segment should you insert at line 05?

Which line of code should you insert at line 07?

You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET. The application connects to a Microsoft SQL Server 2005 database.

You write the following code segment in the exception handler of the application. (Line numbers are included 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 ensure that the original severity level of the error is included in the error message for each SQL error that occurs.

Which line of code should you insert at line 07?

Which line of code should you insert at line 09?

You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET. The application connects to a Microsoft SQL Server 2005 database.

The application populates a DataSet object by using a SqlDataAdapter object. You use the DataSet object to update the Categories database table in the database.
You write the following code segment. (Line numbers are included for reference only.)

01 SqlDataAdapter dataAdpater = new SqlDataAdapter("SELECT CategoryID, CategoryName FROM Categories", connection);
02 SqlCommandBuilder builder = new SqlCommandBuilder(dataAdpater);
03 DataSet ds = new DataSet();
04 dataAdpater.Fill(ds);
05 foreach (DataRow categoryRow in ds.Tables[0].Rows)
06 {
07 if (string.Compare(categoryRow["CategoryName"].ToString(), searchValue, true) == 0)
08 {
09
10 }
11 }
12 dataAdpater.Update(ds);

You need to remove all the records from the Categories database table that match the value of the searchValue variable.

Which line of code should you insert at line 09?

Which code segment should you insert at line 05?

You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET. The application connects to a Microsoft SQL Server 2005 database.

The application uses the following stored procedure.

CREATE PROCEDURE [dbo].[UpdateShippers]
@CountryCode NVarchar(10),
@NewRateCode int

AS
BEGIN

Update dbo.Shippers
SET RateCode = @NewRateCode
Where CountryCode = @CountryCode

RETURN @@ROWCOUNT

END

You write the following code segment. (Line numbers are included for reference only.)

01 using (SqlConnection connection = new SqlConnection(connectionString))
02 {
03 connection.Open();
04 SqlCommand command = new SqlCommand("UpdateShippers", connection);
05
06 command.ExecuteNonQuery();
07 }

You need to ensure that the application can update the Shippers table.

Which code segment should you insert at line 05?

Which code segment should you insert at line 03?

You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET.

The application fills a DataSet object named custDS with customer records.
You write the following code segment. (Line numbers are included for reference only.)

01 System.IO.StreamWriter xmlSW =
02 new System.IO.StreamWriter("Customers.xml");
03
04 xmlSW.Close();

You need to write the content of the custDS object to the Customers.xml file as XML data along with inline XML schema.

Which code segment should you insert at line 03?