PrepAway - Latest Free Exam Questions & Answers

Tag: 70-561

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?

Which code segment should you use?

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 database contains two tables named Customer and Address. The application uses a DataSet object that contains two DataTable objects.
The DataTable objects reference the Customer table and the Address table.

You write the following code segment.

DataSet CustAddressDS= new DataSet();
CustAddressDS.EnforceConstraints = true;
DataRelation custAddrRel = new DataRelation("CustAddrRel", custAddressDS.Tables["Customer"].Columns["CustomerID"], CustAddressDS.Tables["Address"].Columns["CustomerID"]);
CustAddressDS.Relations.Add(custAddrRel);

There are 200 records in the Customer table that are related to records in the Address table. You need to ensure that the application meets the following requirements:

It throws an exception when you attempt to delete related records.
It updates the related records in the Address table when you update records in the Customer table.

Which code segment should you use?

Which code segment should you insert at line 08?

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 create a DataSet named northwind. The northwind DataSet contains two related tables named Customers and Orders.
You write the following code segment. (Line numbers are included for reference only.)

01 private void Page_Load(object sender, EventArgs e)
02 {
03 this.ordTblAdap.Fill(this.northwind.Orders);
04 this.custTblAdap.Fill(this.northwind.Customers);
05 }
06 private void custBindNavSaveItem_Click(object sender, EventArgs e)
07 {
08
09 }

The two tables in the northwind DataSet are updated frequently. You need to ensure that the application commits all the updates to the two tables before it saves the data to the database.

Which code segment should you insert at line 08?

Which code segment should you add?

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 database contains a table named Categories. The Categories table has a primary key identity column named CategoryID.
The application inserts new records by using the following stored procedure.

CREATE PROCEDURE dbo.InsertCategory
@CategoryName nvarchar(15),
@Identity int OUT

AS
INSERT INTO Categories (CategoryName) VALUES(@CategoryName)
SET @Identity = SCOPE_IDENTITY()
RETURN @@ROWCOUNT

You write the following code segment.

SqlDataAdapter adapter = new SqlDataAdapter("SELECT categoryID, CategoryName FROM dbo.Categories",connection);
adapter.InsertCommand = new SqlCommand("dbo.InsertCategory", connection);
adapter.InsertCommand.CommandType = commandType.StoredProcedure;
adapter.InsertCommand.Parameters.Add(new SqlParameter("@CategoryName", SqlDbType.NVarChar, 15,"CategoryName"));

You need to retrieve the identity value for the newly created record.

Which code segment should you add?


Page 6 of 8« First...45678