PrepAway - Latest Free Exam Questions & Answers

Author: admin

What should you do to ensure that only 10 new records are downloaded?

You create a Microsoft Windows Mobilebased 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 caches data from the database server.
You write the following code segment. (Line numbers are included for reference only.)

01 public class MySyncProvider : DbServerSyncProvider{
02 public MySyncProvider (){
03 SqlConnection serverConn = new SqlConnection("SERVER = .; Database = pubs; uid = sa;");
04 this.Connection = serverConn;
05
06 this.BatchSize = 10;
07 }
08
09 }

You need to ensure that only 10 new records are downloaded whenever the application synchronizes.

What should you do?

What should you do to ensure that the method is successfully executed?

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 DDL statement.

CREATE TABLE [dbo].[tblTest](
[C1] [int] IDENTITY(1,1) NOT NULL,
[C2] [char](4) NULL,
[C3] NUMERIC(1,1) NOT NULL,
[C4] AS (C1*C3)
) ON [PRIMARY]

The application contains a method named update. The update method uses the following code segment.

SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM tblTest",sc);
da.UpdateCommand = new SqlCommand("UPDATE tblTest SET C2 = @C2, c3 = @C3, C4 = @C4 WHERE C1 = @C1", sc);

da.UpdateCommand.Parameters.Add("@C1", SqlDbType.Int, 4, "C1");

SqlParameter prm1 = new SqlParameter("@C2", SqlDbType.Char, 4);
prm1.SourceColumn = "C2";
da.UpdateCommand.Parameters.Add(prm1);

SqlParameter prm2 = new SqlParameter("@C3", SqlDbType.Decimal,4);
prm2.SourceColumn = "C3";
da.UpdateCommand.Parameters.Add(prm2);

SqlParameter prm3 = new SqlParameter("@C4", SqlDbType.Char, 4);
prm3.SourceColumn = "C4";
da.UpdateCommand.Parameters.Add(prm3);

When you execute the method, a SqlException exception is thrown.You need to ensure that the method is successfully executed.

What should you do?

What should you do to ensure that the application updates only records without optimistic concurrency violatio

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 that contains a table named Customers. Concurrent users update the Customers table frequently.
You write the following code segment. (Line numbers are included for reference only.)

01 SqlDataAdapter adapter = new SqlDataAdapter("SELECT CustomerID, CompanyName, LastUpdated" + " FROM Customers ORDER BY CustomerID", connection);
02 adapter.UpdateCommand = new SqlCommand("UPDATE Customers Set CompanyName = @CompanyName" + " WHERE CustomerID = @CustomerID AND " + "LastUpdated = @LastUpdated", connection);
03 adapter.UpdateCommand.Parameters.Add("@CustomerID", SqlDbType.Int, 0, "CustomerID");
04 adapter.UpdateCommand.Parameters.Add("@CompanyName", SqlDbType.NVarChar, 30, "CompanyName");
05 SqlParameter parameter = adapter.UpdateCommand.Parameters.Add("@LastUpdated", SqlDbType.Timestamp, 0, "LastUpdated");
06 parameter.SourceVersion = DataRowVersion.Original;
07

You need to ensure that the application updates only records without optimistic concurrency violations.

What should you do?

What should you do to ensure that the application continues to execute while cmd is executing?

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 connection string of the application is defined in the following manner.

"Server=Prod;Database=WingtipToys;Integrated Security=SSPI;Asynchronous Processing=true"

The application contains the following code segment. (Line numbers are included for reference only.)

01 protected void UpdateData(SqlCommand cmd) {
02 cmd.Connection.Open();
03
04 lblResult.Text = "Updating …";
05 }

The cmd object takes a long time to execute. You need to ensure that the application continues to execute while cmd is executing.

What should you do?

What should you do to configure the BackgroundWorker component appropriately to prevent the application?

You are creating a Windows application by using the .NET Framework 3.5.
The Windows application has print functionality. You create an instance of a BackgroundWorker component named backgroundWorker1.
You discover that when the application attempts to cancel the background process, you receive a System.InvalidOperationException exception on the following code segment:

backgroundWorker1.CancelAsync();

You need to configure the BackgroundWorker component appropriately to prevent the application from generating exceptions.
What should you do?