Free Cheat-test Samples and Demo Questions Download
Adobe exams Adobe
Apple exams Apple
Avaya exams Avaya
Check Point exams Check Point
Cisco exams Cisco
Citrix exams Citrix
CIW exams CIW
CompTIA exams CompTIA
CWNP exams CWNP
EC-Council exams EC-Council
EMC exams EMC
Exin exams Exin
Fortinet exams Fortinet
GIAC exams GIAC
Hitachi exams Hitachi
HP exams HP
IBM exams IBM
Isaca exams Isaca
ISC exams ISC
ISEB exams ISEB
Juniper exams Juniper
LPI exams LPI
McAfee exams McAfee
Microsoft exams Microsoft
Oracle exams Oracle
PMI exams PMI
Riverbed exams Riverbed
SNIA exams SAP
Sun exams SAS
Symantec exams Symantec
VMware exams VMware
All certification exams

Microsoft 70-568 Exam - Cheat-Test.com

Free 70-568 Sample Questions:

1. You are creating a Windows Forms application by using the .NET Framework 3.5.
You create a new form in the application. You add a ContextMenuStrip control named ctxMenu to the form.
You have a user-defined class named CustomControl.
You write the following code segment in the application. (Line numbers are included for reference only.)
01 CustomControl myControl = new CustomControl();
02 You need to ensure that an instance of CustomControl is displayed on the form as a top-level item of the ctxMenu control.
Which code segment should you add at line 02?
A. ToolStripControlHost host = new ToolStripControlHost(myControl);
ctxMenu.Items.Add(host);
B. ToolStripPanel panel = new ToolStripPanel();
panel.Controls.Add(myControl);
ctxMenu.Controls.Add(panel);
C. ToolStripContentPanel panel = new ToolStripContentPanel();
panel.Controls.Add(myControl);
ctxMenu.Controls.Add(panel);
D. ToolStripMenuItem menuItem = new ToolStripMenuItem();
ToolStripControlHost host = new ToolStripControlHost(myControl);
menuItem.DropDownItems.Add(host);
ctxMenu.Items.Add(menuItem);
Answer: A

2. You are creating a Windows Forms application by using the .NET Framework 3.5.
You create a new form in the application. You add a ContextMenuStrip control named ctxMenu to the form.
You have a user-defined class named CustomControl.
You write the following code segment in the application. (Line numbers are included for reference only.)
01 Dim myControl As New CustomControl()
02 You need to ensure that an instance of CustomControl is displayed on the form as a top-level item of the ctxMenu control.
Which code segment should you add at line 02?
A. Dim host As New ToolStripControlHost(myControl)
ctxMenu.Items.Add(host)
B. Dim panel As New ToolStripPanel()
panel.Controls.Add(myControl)
ctxMenu.Controls.Add(panel)
C. Dim panel As New ToolStripContentPanel()
panel.Controls.Add(myControl)
ctxMenu.Controls.Add(panel)
D. Dim menuItem As New ToolStripMenuItem()
Dim host As New ToolStripControlHost(myControl)
menuItem.DropDownItems.Add(host)
ctxMenu.Items.Add(menuItem)
Answer: A

3. You are creating a Windows Forms application by using the .NET Framework 3.5.
You create a new form in your application. You add a PrintDocument control named pntDoc to the form.
To support the print functionality, you write the following code segment in the application. (Line numbers are included for reference only.)
01 pntDoc.BeginPrint +=
new PrintEventHandler(PrintDoc_BeginPrint);
02 ...
03 bool canPrint = CheckPrintAccessControl();
04 if (!canPrint) {
05
06 }
07
You need to ensure that the following requirements are met:
¡¤ When the user has no print access, font and file stream initializations are not executed and the print operation is cancelled.
¡¤Print operations are logged whether or not the user has print access
What should you do?
A. Add the following code segment at line 05.
pntDoc.BeginPrint -= new PrintEventHandler(PrintDoc_BeginPrint);
pntDoc.BeginPrint +=
new PrintEventHandler((obj, args) => args.Cancel = true);
Add the following code segment at line 07.
pntDoc.BeginPrint +=
new PrintEventHandler((obj1, args1) => LogPrintOperation());
B. Add the following code segment at line 05.
pntDoc.BeginPrint +=
new PrintEventHandler(delegate(object obj, PrintEventArgs args){});
Add the following code segment at line 07.
pntDoc.BeginPrint -= new PrintEventHandler(PrintDoc_BeginPrint);
pntDoc.BeginPrint +=
new PrintEventHandler((obj1, args1) => LogPrintOperation());
C. Add the following code segment at line 05.
pntDoc.BeginPrint -= new PrintEventHandler(PrintDoc_BeginPrint);
pntDoc.BeginPrint -=
new PrintEventHandler(delegate(object obj, PrintEventArgs args){});
Add the following code segment at line 07.
pntDoc.BeginPrint -=
new PrintEventHandler((obj1, args1) => LogPrintOperation());
D. Add the following code segment at line 05.
pntDoc.BeginPrint -=
new PrintEventHandler((obj, args) => args.Cancel = true);
Add the following code segment at line 07.
pntDoc.BeginPrint += new PrintEventHandler(PrintDoc_BeginPrint);
pntDoc.BeginPrint -=
new PrintEventHandler((obj1, args1) => LogPrintOperation());
Answer: A

4. You are creating a Windows Forms application by using the .NET Framework 3.5.
You create a new form in your application. You add a PrintDocument control named pntDoc to the form.
To support the print functionality, you write the following code segment in the application. (Line numbers are included for reference only.)
01 AddHandler pntDoc.BeginPrint, _
AddressOf PrintDoc_BeginPrint
02 ...
03 Dim canPrint As Boolean = CheckPrintAccessControl()
04 If canPrint = False Then
05
06 End If
07
You need to ensure that the following requirements are met:
¡¤ When the user has no print access, font and file stream initializations are not executed and the print operation is cancelled.
¡¤Print operations are logged whether or not the u er has print access.
What should you do?
A. Add the following code segment at line 05.
RemoveHandler pntDoc.BeginPrint, AddressOf PrintDoc_BeginPrint
AddHandler pntDoc.BeginPrint, _
Function(obj1, args1) args1.Cancel = True
Add the following code segment at line 07.
AddHandler pntDoc.BeginPrint, AddressOf
LogPrintOperation
B. Add the following code segment at line 05.
AddHandler pntDoc.BeginPrint, AddressOf EmptyEventHandler
Add the following code segment at line 07.
RemoveHandler pntDoc.BeginPrint, AddressOf PrintDoc_BeginPrint
AddHandler pntDoc.BeginPrint, AddressOf
LogPrintOperation
C. Add the following code segment at line 05.
RemoveHandler pntDoc.BeginPrint, AddressOf PrintDoc_BeginPrint
RemoveHandler pntDoc.BeginPrint, AddressOf EmptyEventHandler
Add the following code segment at line 07.
RemoveHandler pntDoc.BeginPrint, AddressOf
LogPrintOperation
D. Add the following code segment at line 05.
AddHandler pntDoc.BeginPrint, _
function(obj1, args1) args1.Cancel = True
Add the following code segment at line 07.
AddHandler pntDoc.BeginPrint, AddressOf PrintDoc_BeginPrint
RemoveHandler pntDoc.BeginPrint, AddressOf
LogPrintOperation
Answer: A

5. You are creating a Windows Forms application by using the .NET Framework 3.5.
You plan to modify a list of orders within a DataGridView control in the application.
You need to ensure that a value is required in the first column of the grid control.
Which code segment should you use?
A. private void dataGridOrders_CellValidated(
object sender, DataGridViewCellEventArgs e) {
if (e.ColumnIndex == 0) {
var cellValue = dataGridOrders[
e.ColumnIndex, e.RowIndex].Value;
if (cellValue == null ||
string.IsNullOrEmpty(cellValue.ToString()))
{
dataGridOrders.EndEdit();
}
}
}
B. private void dataGridOrders_Validated(
object sender, EventArgs e) {
if (dataGridOrders.CurrentCell.ColumnIndex == 0) {
var cellValue = dataGridOrders.Text;
if (cellValue == null ||
string.IsNullOrEmpty(cellValue.ToString()))
{
dataGridOrders.EndEdit();
}
}
}
C. private void dataGridOrders_Validating(
object sender, CancelEventArgs e) {
if (dataGridOrders.CurrentCell.ColumnIndex == 0) {
var cellValue = dataGridOrders.Text;
if (cellValue == null ||
string.IsNullOrEmpty(cellValue.ToString()))
{
e.Cancel = true;
}
}
}
D. private void dataGridOrders_CellValidating(
object sender, DataGridViewCellValidatingEventArgs e) {
if (e.ColumnIndex == 0) {
if (e.FormattedValue == null ||
string.IsNullOrEmpty(e.FormattedValue.ToString()))
{
e.Cancel = true;
}
}
}
Answer: D

6. You are creating a Windows Forms application by using the .NET Framework 3.5.
You plan to modify a list of orders within a DataGridView control in the application.
You need to ensure that a value is required in the first column of the grid control.
Which code segment should you use?
A. Private Sub dataGridOrders_CellValidated( _
ByVal sender As Object, _
ByVal e As DataGridViewCellEventArgs) _
Handles dataGridOrders.CellValidated
If e.ColumnIndex = 0 Then
Dim cellValue = dataGridOrders(e.ColumnIndex, e.RowIndex).Value
If cellValue = Nothing _
Or String.IsNullOrEmpty(cellValue.ToString()) Then
dataGridOrders.EndEdit()
End If
End If
End Sub
B. Private Sub dataGridOrders_Validated( _
ByVal sender As Object, _
ByVal e As EventArgs) _
Handles dataGridOrders.Validated
If dataGridOrders.CurrentCell.ColumnIndex = 0 Then
Dim cellValue = dataGridOrders.Text
If cellValue = Nothing Or _
String.IsNullOrEmpty(cellValue.ToString()) Then
dataGridOrders.EndEdit()
End If
End If
End Sub
C. Private Sub dataGridOrders_Validating( _
ByVal sender As Object, _
ByVal e As CancelEventArgs) _
Handles dataGridOrders.Validating
If dataGridOrders.CurrentCell.ColumnIndex = 0 Then
Dim cellValue = dataGridOrders.Text
If cellValue = Nothing Or _
String.IsNullOrEmpty(cellValue.ToString()) Then
e.Cancel = True
End If
End If
End Sub
D. Private Sub dataGridOrders_CellValidating( _
ByVal sender As Object, _
ByVal e As DataGridViewCellValidatingEventArgs) _
Handles dataGridOrders.CellValidating
If e.ColumnIndex = 0 Then
If e.FormattedValue = Nothing _
Or String.IsNullOrEmpty(e.FormattedValue.ToString()) Then
e.Cancel = True
End If
End If
End Sub
Answer: D

7. You are creating a Windows Forms application by using the .NET Framework 3.5.
You write the following code segment to bind a list of categories to a drop-down list. (Line numbers are included for reference only.)
01 OleDbConnection cnnNorthwind =
new OleDbConnection(connectionString);
02 OleDbCommand cmdCategory = new OleDbCommand(
"SELECT CategoryID, CategoryName FROM Categories ORDER BY
CategoryName", cnnNorthwind);
03 OleDbDataAdapter daCategory = new
OleDbDataAdapter(cmdCategory);
04 DataSet dsCategory = new DataSet();
05 daCategory.Fill(dsCategory);
06
You need to ensure that the drop-down list meets the following requirements:
¡¤Displays all category names
¡¤Uses the category ID as the selected item value
Which code segment should you add at line 06?
A. ddlCategory.DataSource = dsCategory;
ddlCategory.DisplayMember = "CategoryName";
ddlCategory.ValueMember = "CategoryID";
B. ddlCategory.DataSource = dsCategory.Tables[0];
ddlCategory.DisplayMember = "CategoryName";
ddlCategory.ValueMember = "CategoryID";
C. ddlCategory.DataBindings.Add("DisplayMember",
dsCategory, "CategoryName");
ddlCategory.DataBindings.Add("ValueMember",
dsCategory, "CategoryID");
D. ddlCategory.DataBindings.Add("DisplayMember",
dsCategory.Tables[0], "CategoryName");
ddlCategory.DataBindings.Add("ValueMember",
dsCategory.Tables[0], "CategoryID");
Answer: B

8. 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. (Line numbers are included for referen ce only.)
01 using (SqlConnection connection = new SqlConnection(connectionString)) {
02 SqlCommand cmd = new SqlCommand(queryString, connection);
03 connection.Open();
04
05 while (sdrdr.Read()){
06 // use the data in the reader
07 }
08 }
You need to ensure that the memory is used efficiently when retrieving BLOBs from the database.
Which code segment should you insert at line 04?
A. SqlDataReader sdrdr =
cmd.ExecuteReader();
B. SqlDataReader sdrdr =
cmd.ExecuteReader(CommandBehavior.Default);
C. SqlDataReader sdrdr =
cmd.ExecuteReader(CommandBehavior.SchemaOnly);
D. SqlDataReader sdrdr =
cmd.ExecuteReader(CommandBehavior.SequentialAccess);
Answer: D

9. You are creating a Windows Forms application by using the .NET Framework 3.5.
You write the following code segment to bind a list of categories to a drop-down list. (Line numbers are included for reference only.)
01 Dim cnnNorthwind As OleDbConnection = _
New OleDbConnection(connectionString)
02 Dim cmdCategory As OleDbCommand = New OleDbCommand( _
"SELECT CategoryID, CategoryName FROM Categories ORDER BY
CategoryName", cnnNorthwind)
03 Dim daCategory As OleDbDataAdapter = _
New OleDbDataAdapter(cmdCategory)
04 Dim dsCategory As DataSet = New DataSet()
05 daCategory.Fill(dsCategory)
06
You need to ensure that the drop-down list meets the following requirements:
¡¤Displays all category names
¡¤Uses the category ID as the selected item value
Which code segment should you add at line 06?
A. ddlCategory.DataSource = dsCategory
ddlCategory.DisplayMember = "CategoryName"
ddlCategory.ValueMember = "CategoryID"
B. ddlCategory.DataSource = dsCategory.Tables(0)
ddlCategory.DisplayMember = "CategoryName"
ddlCategory.ValueMember = "CategoryID"
C. ddlCategory.DataBindings.Add("DisplayMember", _
dsCategory, "CategoryName")
ddlCategory.DataBindings.Add("ValueMember", _
dsCategory, "CategoryID")
D. ddlCategory.DataBindings.Add("DisplayMember", _
dsCategory.Tables(0), "CategoryName")
ddlCategory.DataBindings.Add("ValueMember", _
dsCategory.Tables(0), "CategoryID")
Answer: B

10. 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. (Line number s are included for reference only.)
01 Using connection As New SqlConnection(connectionString)
02 Dim cmd As New SqlCommand(queryString, connection)
03 connection.Open()
04
05 While sdrdr.Read()
06 ' use the data in the reader
07 End While
08 End Using
You need to ensure that the memory is used efficiently when retrieving BLOBs from the database.
Which code segment should you insert at line 04?
A. Dim sdrdr As SqlDataReader = _
cmd.ExecuteReader()
B. Dim sdrdr As SqlDataReader = _
cmd.ExecuteReader(CommandBehavior.[Default])
C. Dim sdrdr As SqlDataReader = _
cmd.ExecuteReader(CommandBehavior.SchemaOnly)
D. Dim sdrdr As SqlDataReader = _
cmd.ExecuteReader(CommandBehavior.SequentialAccess)
Answer: D

11. 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.
string query = "Select EmpNo, EmpName from dbo.Table_1;
select Name,Age from dbo.Table_2";
SqlCommand command = new SqlCommand(query, connection);
SqlDataReader reader = command.ExecuteReader();
You need to ensure that the application reads all the rows returned by the code segment.
Which code segment should you use?
A. while (reader.NextResult())
{
Console.WriteLine(String.Format("{0}, {1}",reader[0], reader[1]));
reader.Read();
}
B. while (reader.Read())
{
Console.WriteLine(String.Format("{0}, {1}",reader[0], reader[1]));
reader.NextResult();
}
C. while (reader.Read())
{
Console.WriteLine(String.Format("{0}, {1}",reader[0], reader[1]));
}
reader.NextResult();
while (reader.Read())
{
Console.WriteLine(String.Format("{0}, {1}",reader[0], reader[1]));
}
D. while (reader.NextResult())
{
Console.WriteLine(String.Format("{0}, {1}",reader[0], r eader[1]));
}
reader.Read();
while (reader.NextResult())
{
Console.WriteLine(String.Format("{0}, {1}",reader[0], reader[1]));
}
Answer: C

12. You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.
You create a Web form and add the following code fragment.
<asp:Repeater ID="rptData" runat="server"
DataSourceID="SqlDataSource1"
ItemDataBound="rptData_ItemDataBound">
<ItemTemplate>
<asp:Label ID="lblQuantity" runat="server"
Text='<%# Eval("QuantityOnHand") %>' />
</ItemTemplate>
</asp:Repeater>
The SqlDataSource1 DataSource control retrieves the Quantity column values from a table named Products.
You write the following code segment to create the rptData_ItemDataBound event handler. (Line numbers are included for reference only.)
01 protected void rptData_ItemDataBound(object sender,
02 RepeaterItemEventArgs e)
03 {
04
05 if(lbl != null)
06 if(int.Parse(lbl.Text) < 10)
07 lbl.ForeColor = Color.Red;
08 }
You need to retrieve a reference to the lblQuantity Label control into a variable named lbl.
Which code segment should you insert at line 04?
A. Label lbl = Page.FindControl("lblQuantity") as Label;
B. Label lbl = e.Item.FindControl("lblQuantity") as Label;
C. Label lbl = rptData.FindControl("lblQuantity") as Label;
D. Label lbl = e.Item.Parent.FindControl("lblQuantity") as Label;
Answer: B

13. 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.
Dim query As String = _
"Select EmpNo, EmpName from dbo.Table_1; " + _
"select Name,Age from dbo.Table_2"
Dim command As New SqlCommand(query, connection)
Dim reader As SqlDataReader = command.ExecuteReade r()
You need to ensure that the application reads all the rows returned by the code segment.
Which code segment should you use?
A. While reader.NextResult()
Console.WriteLine([String].Format("{0}, {1}", reader(0), reader(1)))
reader.Read()
End While
B. While reader.Read()
Console.WriteLine([String].Format("{0}, {1}", reader(0), reader(1)))
reader.NextResult()
End While
C. While reader.Read()
Console.WriteLine([String].Format("{0}, {1}", reader(0), reader(1)))
End While
reader.NextResult()
While reader.Read()
Console.WriteLine([String].Format("{0}, {1}", reader(0), reader(1)))
End While
D. While reader.NextResult()
Console.WriteLine([String].Format("{0}, {1}", reader(0), reader(1)))
End While
reader.Read()
While reader.NextResult()
Console.WriteLine([String].Format("{0}, {1}", reader(0), reader(1)))
End While
Answer: C

14. You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.
You create a Web form and add the following code fragment.
<asp:Repeater ID="rptData" runat="server"
DataSourceID="SqlDataSource1"
ItemDataBound="rptData_ItemDataBound">
<ItemTemplate>
<asp:Label ID="lblQuantity" runat="server"
Text='<%# Eval("QuantityOnHand") %>' />
</ItemTemplate>
</asp:Repeater>
The SqlDataSource1 DataSource control retrieves the Quantity column values from a table named Products.
You write the following code segment to create the rptData_ItemDataBound event handler. (Line numbers are included for reference only.)
01 Protected Sub rptData_ItemDataBound(ByVal sender As Object, _
02 ByVal e As RepeaterItemEventArgs)
03 ?
04 If lbl IsNot Nothing Then
05 If Integer.Parse(lbl.Text) < 10 Then
06 lbl.ForeColor = Color.Red
07 End If
08 End If
09 End Sub
You need to retrieve a reference to the lblQuantity Label control into a variable named lbl.
Which code segment should you insert at line 03?
A. Dim lbl As Label = _
TryCast(Page.FindControl("lblQuantity"), Label)
B. Dim lbl As Label = _
TryCast(e.Item.FindControl("lblQuantity"), Label)
C. Dim lbl As Label = _
TryCast(rptData.FindControl("lblQuantity"), Label)
D. Dim lbl As Label = _
TryCast(e.Item.Parent.FindControl("lblQuantity"), Label)
Answer: B

15. You are creating a Windows Forms application by using the .NET Framework 3.5.
You write the following code segment to update multiple databases on a SQL Server 2008 database.
(Line numbers are included for reference only.)
01 string connectionStringCustomer = @"Data
Source=CUSTOMER;Integrated Security= SSPI;";
02 string connectionStringOrders = @"Data Source=ORDER
;Integrated Security= SSPI;";
03 SqlCommand cmdCustomer = new SqlCommand();
04 SqlCommand cmdOrders = new SqlCommand();
05 SqlConnection cnnCustomer =
new SqlConnection(connectionStringCustomer);
06 SqlConnection cnnOrders =
new SqlConnection(connectionStringOrders);
07
You need to ensure that all database updates are included in a single distributed transaction.
Which code fragment should you add on Line 07?
A. cnnCustomer.Open();
cnnOrders.Open();
...
cmdOrders.ExecuteNonQuery();
...
cmdCustomer.ExecuteNonQuery();
cnnOrders.Close();
cnnCustomer.Close();
B. TransactionScope scope = new TransactionScope();
cnnCustomer.Open();
cnnOrders.Open();
...
cmdOrders.ExecuteNonQuery();
...
cmdCustomer.ExecuteNonQuery();
cnnOrders.Close();
cnnCustomer.Close();
scope.Complete();
C. TransactionScope customerScope =
new TransactionScope() {
using (SqlConnection cnnCustomer =
new SqlConnection (connectionStringCustomer)) { }
customerScope.Complete(); }
using (TransactionScope ordersScope =
new TransactionScope()) {
using (SqlConnection cnnOrders =
new SqlConnection(connectionStringOrders)) { }
ordersScope.Complete(); }
D. try {
cmdOrders.Transaction = cnnOrders.BeginTransaction();
...
cmdOrders.ExecuteNonQuery();
...
cmdCustomer.Transaction = cnnCustomer.BeginTransaction();
...
cmdCustomer.ExecuteNonQuery();
cmdCustomer.Transaction.Commit();
cmdOrders.Transaction.Commit();
}catch {
cmdCustomer.Transaction.Rollback();
cmdOrders.Transaction.Rollback();
}
Answer: B

16. You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET.
The application has a DataTable object named OrderDetailTable. The object has the following columns:
¡¤I
¡¤OrderI
¡¤ProductI
•Quantity
¡¤LineTota
The OrderDetailTable object is populated with data provided by a business partner. Some of the records contain a null value in the LineTotal field and 0 in the Quantity field.
You write the following code segment. (Line numbers are inc luded for reference only.)
01 DataColumn col = new DataColumn("UnitPrice", typeof(decimal));
02
03 OrderDetailTable.Columns.Add(col);
You need to add a DataColumn named UnitPrice to the OrderDetailTable object.
Which line of code should you insert at line 02?
A. col.Expression = "LineTotal/Quantity";
B. col.Expression = "LineTotal/ISNULL(Quantity, 1)";
C. col.Expression = "LineTotal.Value/ISNULL(Quantity.Value,1)";
D. col.Expression = "iif(Quantity > 0, LineTotal/Quantity, 0)";
Answer: D

17. You are creating a Windows Forms application by using the .NET Framework 3.5.
You write the following code segment to update multiple databases on a SQL Server 2008 database.
(Line numbers are included for reference only.)
01 Dim connectionStringCustomer As String = "Data
Source=CUSTOMER;Integrated Security = SSPI;"
02 Dim connectionStringOrders As String = "Data
Source=ORDER;Integrated Security = SSPI;"
03 Dim cmdCustomer As SqlCommand = New SqlCommand()
04 Dim cmdOrders As SqlCommand = New SqlCommand()
05 Dim cnnCustomer As SqlConnection = New
SqlConnection(connectionStringCustomer)
06 Dim cnnOrders As SqlConnection = New
SqlConnection(connectionStringOrders)
07
You need to ensure that all database updates are included in a single distributed trans action.
Which code fragment should you add at line 07?
A. cnnCustomer.Open()
cnnOrders.Open()
cmdOrders.ExecuteNonQuery()
cmdCustomer.ExecuteNonQuery()
cnnOrders.Close()
cnnCustomer.Close()
B. Dim scope As TransactionScope = New TransactionScope()
cnnCustomer.Open()
cnnOrders.Open()
cmdOrders.ExecuteNonQuery()
cmdCustomer.ExecuteNonQuery()
cnnOrders.Close()
cnnCustomer.Close()
scope.Complete();
C. Using customerScope = New TransactionScope()
cnnCustomer.Open()
cmdCustomer.ExecuteNonQuery()
cnnCustomer.Close()
customerScope.Complete()
End Using
Using ordersScope = New TransactionScope()
cnnOrders.Open()
cmdOrders.ExecuteNonQuery()
cnnOrders.Close()
ordersScope.Complete()
End Using
D. Try
cmdOrders.Transaction = cnnOrders.BeginTransaction()
cmdOrders.ExecuteNonQuery()
cmdCustomer.Transaction = cnnCustomer.BeginTransaction()
cmdCustomer.ExecuteNonQuery()
cmdCustomer.Transaction.Commit()
cmdOrders.Transaction.Commit()
Catch ex As Exception
cmdCustomer.Transaction.Rollback()
cmdCustomer.Transaction.Rollback()
End Try
Answer: B

18. You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET.
The application has a DataTable object named OrderDetailTable. The object has the following columns:
¡¤I
¡¤OrderI
¡¤ProductI
¡¤Quantit
¡¤LineTota
The OrderDetailTable object is populated with data provided by a business partner. Some of the records contain a null value in the LineTotal field and 0 in the Quantity field.
You write the following code segment. (Line numbers are included for reference only.)
01 Dim col As New DataColumn("UnitPrice", GetType(Decimal))
02
03 OrderDetailTable.Columns.Add(col)
You need to add a DataColumn named UnitPrice to the OrderDetailTable object.
Which line of code should you insert at line 02?
A. col.Expression = "LineTotal/Quantity"
B. col.Expression = "LineTotal/ISNULL(Quantity, 1)"
C. col.Expression = "LineTotal.Value/ISNULL(Quantity.Value, 1)"
D. col.Expression = "iif(Quantity > 0, LineTotal/Quantity, 0)"
Answer: D

19. You are creating a Windows Forms application by using the .NET Framework 3.5.
You write a code segment to connect to a Microsoft Access database and populate a DataSet.
You need to ensure that the application meets the following requirements:
¡¤Itdisplays all database exceptions.
¡¤It logs all other exceptions by using the LogExceptionToFile
Which code segment should you use?
A. try
{
categoryDataAdapter.Fill(dsCategory);
}
catch (SqlException ex)
{
MessageBox.Show(ex.Message, "Exception");
LogExceptionToFile(ex.Message);
}
B. try
{
categoryDataAdapter.Fill(dsCategory);
}
catch (SqlException ex)
{
MessageBox.Show(ex.Message, "Exception");
}
catch (Exception ex)
{
LogExceptionToFile(ex.Message);
}
C. try
{
categoryDataAdapter.Fill(dsCategory);
}
catch (OleDbException ex)
{
MessageBox.Show(ex.Message, "Exception");
}
catch (Exception ex)
{
LogExceptionToFile(ex.Message);
}
D. try
{
categoryDataAdapter.Fill(dsCategory);
}
catch (OleDbException ex)
{
MessageBox.Show(ex.Message, "Exception");
LogExceptionToFile(ex.Message);
}
Answer: C

20. You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET.
The application contains a DataSet object named orderDS. The object contains a table named Order as shown in the following exhibit.
The application uses a SqlDataAdapter object named daOrder to populate the Order table.
You write the following code segment. (Line numbers are included for reference only.)
01 private void FillOrderTable(int pageIndex) {
02 int pageSize = 5;
03
04 }
You need to fill the Order table with the next set of 5 records for each increase in the pageIndex value.
Which code segment should you insert at line 03?
A. string sql = "SELECT SalesOrderID, CustomerID, OrderD ate FROM
Sales.SalesOrderHeader";
daOrder.SelectCommand.CommandText = sql;
daOrder.Fill(orderDS, pageIndex, pageSize, "Order");
B. int startRecord = (pageIndex - 1) * pageSize;
string sql = "SELECT SalesOrderID, CustomerID, OrderDate FROM
Sales.SalesOrderHeader";
daOrder.SelectCommand.CommandText = sql;
daOrder.Fill(orderDS, startRecord, pageSize, "Order");
C. string sql = string.Format("SELECT TOP {0} SalesOrderID,
CustomerID,
OrderDate FROM Sales.SalesOrderHeader WHERE SalesOrderID > {1}",
pageSize, pageIndex);
daOrder.SelectCommand.CommandText = sql;
daOrder.Fill(orderDS, "Order");
D. int startRecord = (pageIndex - 1) * pageSize;
string sql = string.Format("SELECT TOP {0} SalesOrderID, CustomerID,
OrderDate FROM Sales.SalesOrderHeader WHERE SalesOrderID > {1}",
pageSize, startRecord);
daOrder.SelectCommand.CommandText = sql;
daOrder.Fill(orderDS, "Order");
Answer: B

21. You are creating a Windows Forms application by using the .NET Framework 3.5.
You write a code segment to connect to a Microsoft Access database and populate a DataSet.
You need to ensure that the application meets the following requirements:
¡¤It displays all database exceptions.
¡¤It logs all other exceptions by using the LogExceptionToFile Which code segment should you use?
A. Try
categoryDataAdapter.Fill(dsCategory)
Catch ex As SqlException
MessageBox.Show(ex.Message, "Exception")
LogExceptionToFile(ex.Message)
End Try
B. Try
categoryDataAdapter.Fill(dsCategory)
Catch ex As SqlException
MessageBox.Show(ex.Message, "Exception")
Catch ex As Exception
LogExceptionToFile(ex.Message)
End Try
C. Try
categoryDataAdapter.Fill(dsCategory)
Catch ex As OleDbException
MessageBox.Show(ex.Message, "Exception")
Catch ex As Exception
LogExceptionToFile(ex.Message)
End Try
D. Try
categoryDataAdapter.Fill(dsCategory)
Catch ex As OleDbException
MessageBox.Show(ex.Message, "Exception")
LogExceptionToFile(ex.Message)
End Try
Answer: C

22. You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET.
The application contains a DataSet object named orderDS. The object contains a table named Order as shown in the following exhibit.
The application uses a SqlDataAdapter object named daOrder to populate the Order table.
You write the following code segment. (Line numbers are included for reference only.)
01 Private Sub FillOrderTable(ByVal pageIndex As Integer)
02 Dim pageSize As Integer = 5
03
04 End Sub
You need to fill the Order table with the next set of 5 records for each increase in the pageIndex value.
Which code segment should you insert at line 03?
A. Dim sql As String = "SELECT SalesOrderID, CustomerID, " + _
"OrderDate FROM Sales.SalesOrderHeader"
daOrder.SelectCommand.CommandText = sql
daOrder.Fill(orderDS, pageIndex, pageSize, "Order")
B. Dim startRecord As Integer = (pageIndex - 1) * pageSize
Dim sql As String = "SELECT SalesOrderID, CustomerID, " + _
"OrderDate FROM Sales.SalesOrderHeader"
daOrder.SelectCommand.CommandText = sql
daOrder.Fill(orderDS, startRecord, pageSize, "O rder")
C. Dim sql As String = _
String.Format("SELECT TOP {0} SalesOrderID, " + _
"CustomerID, OrderDate FROM Sales.SalesOrderHeader " + _
"WHERE SalesOrderID > {1}", pageSize, pageIndex)
daOrder.SelectCommand.CommandText = sql
daOrder.Fill(orderDS, "Order")
D. Dim startRecord As Integer = (pageIndex - 1) * pageSize
Dim sql As String = _
String.Format("SELECT TOP {0} SalesOrderID, " + _
"CustomerID, OrderDate FROM Sales.SalesOrderHeader " + _
"WHERE SalesOrderID > {1}", pageSize, startRecord)
daOrder.SelectCommand.CommandText = sql
daOrder.Fill(orderDS, "Order")
Answer: B

23. 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 analyzes large amounts of transaction data that are stored in a different database.
You write the following code segment. (Line numbers are included for reference only.)
01 using (SqlConnection connection = new
SqlConnection(sourceConnectionString))
02 using (SqlConnection connection2 = new
SqlConnection(destinationConnectionString))
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 the transaction data to the database of the application.
Which code segment should you insert at line 11?
A. reader.Read()
bulkCopy.WriteToServer(reader);
B. bulkCopy.DestinationTableName = "Transactions";
bulkCopy.WriteToServer(reader);
C. bulkCopy.DestinationTableName = "Transactions";
bulkCopy.SqlRowsCopied += new
SqlRowsCopiedEventHandler(bulkCopy_SqlRowsCopied);
D. while (reader.Read())
{
bulkCopy.WriteToServer(reader);
}
Answer: B

24. 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 analyzes large amounts of transaction data that are stored in a different database.
You write the following code segment. (Line numbers are included for reference only.)
01 Using connection As New SqlConnection(sourceConnectionString)
02 Using connection2 As _
New SqlConnection(destinationConnectionString)
03 Using command As New SqlCommand()
04 connection.Open()
05 connection2.Open()
06 Using reader As SqlDataReader = command.ExecuteReader()
07 Using bulkCopy As New SqlBulkCopy(connection2)
08
09 End Using
10 End Using
11 End Using
12 End Using
13 End Using
You need to copy the transaction data to the database of the application.
Which code segment should you insert at line 08?
A. reader.Read()
bulkCopy.WriteToServer(reader)
B. bulkCopy.DestinationTableName = "Transactions"
bulkCopy.WriteToServer(reader)
C. bulkCopy.DestinationTableName = "Transactions"
AddHandler bulkCopy.SqlRowsCopied, _
AddressOf bulkCopy_SqlRowsCopied
D. While reader.Read()
bulkCopy.WriteToServer(reader)
End While
Answer: B

25. You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET. The application uses Microsoft SQL Server 2005.
You write the following code segment. (Line numbers are include d for reference only.)
01 String myConnString = "User
02 ID=<username>;password=<strong password>;Initial
03 Catalog=pubs;Data Source=myServer";
04 SqlConnection myConnection = new
05 SqlConnection(myConnString);
06 SqlCommand myCommand = new SqlCommand();
07 DbDataReader myReader;
08 myCommand.CommandType =
09 CommandType.Text;
10 myCommand.Connection = myConnection;
11 myCommand.CommandText = "Select * from Table1;
Select * from Table2;";
12 int RecordCount = 0;
13 try
14 {
15 myConnection.Open();
16
17 }
18 catch (Exception ex)
19 {
20 }
21 finally
22 {
23 myConnection.Close();
24 }
You need to compute the total number of records processed by the Select queries in the RecordCount variable.
Which code segment should you insert at line 16?
A. myReader = myCommand.ExecuteReader();
RecordCount = myReader.RecordsAffected;
B. while (myReader.Read())
{
//Write logic to process data for the first result.
}
RecordCount = myReader.RecordsAffected;
C. while (myReader.HasRows)
{
while (myReader.Read())
{
//Write logic to process data for the second result.
RecordCount = RecordCount + 1;
myReader.NextResult();
}
}
D. while (myReader.HasRows)
{
while (myReader.Read())
{
//Write logic to process data for the second result.
RecordCount = RecordCount + 1;
}
myReader.NextResult();
}
Answer: D

26. You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET. The application uses Microsoft SQL Server 2005.
You write the following code segment. (Line numbers are included for reference only.)
01 Dim myConnString As String = _
02 "User ID=<username>;password=<strong password>;" + _
03 "Initial Catalog=pubs;Data Source=myServer"
04 Dim myConnection As New SqlConnection(myConnSt ring)
05 Dim myCommand As New SqlCommand()
06 Dim myReader As DbDataReader
07 myCommand.CommandType = CommandType.Text
08 myCommand.Connection = myConnection
09 myCommand.CommandText = _
10 "Select * from Table1;Select * from Table2;"
11 Dim RecordCount As Integer = 0
12 Try
13 myConnection.Open()
14
15 Catch ex As Exception
16 Finally
17 myConnection.Close()
18 End Try
You need to compute the total number of records processed by the Select queries in the RecordCount variable.
Which code segment should you insert at line 14?
A. myReader = myCommand.ExecuteReader()
RecordCount = myReader.RecordsAffected
B. While myReader.Read()
'Write logic to process data for the first result.
End While
RecordCount = myReader.RecordsAffected
C. While myReader.HasRows
While myReader.Read()
'Write logic to process data for the second result.
RecordCount = RecordCount + 1
myReader.NextResult()
End While
End While
D. While myReader.HasRows
While myReader.Read()
'Write logic to process data for the second result.
RecordCount = RecordCount + 1
End While
myReader.NextResult()
End While
Answer: D

27. You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.
You create a composite custom control named MyCont rol.
You need to add an instance of the OrderFormData control to the MyControl control.
Which code segment should you use?
A. protected override void CreateChildControls() {
Controls.Clear();
OrderFormData oFData = new OrderFormData("OrderForm");
Controls.Add(oFData);
}
B. protected override void
RenderContents(HtmlTextWriter writer) {
OrderFormData oFData = new OrderFormData("OrderForm");
oFData.RenderControl(writer);
}
C. protected override void EnsureChildControls() {
Controls.Clear();
OrderFormData oFData = new OrderFormData("OrderForm");
oFData.EnsureChildControls();
if (!ChildControlsCreated)
CreateChildControls();
}
D. protected override ControlCollection
CreateControlCollection() {
ControlCollection controls = new ControlCollection(this);
OrderFormData oFData = new OrderFormData("OrderForm");
controls.Add(oFData);
return controls;
}
Answer: A

28. You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.
You create a composite custom control named MyControl.
You need to add an instance of the OrderFormData control to the MyControl control.
Which code segment should you use?
A. Protected Overloads Overrides Sub _
CreateChildControls()
Controls.Clear()
Dim oFData As New OrderFormData("OrderForm")
Controls.Add(oFData)
End Sub
B. Protected Overloads Overrides Sub _
RenderContents(ByVal writer As HtmlTextWriter)
Dim oFData As New OrderFormData("OrderForm")
oFData.RenderControl(writer)
End Sub
C. Protected Overloads Overrides Sub _
EnsureChildControls()
Controls.Clear()
Dim oFData As New OrderFormData("OrderForm")
oFData.EnsureChildControls()
If Not ChildControlsCreated Then
CreateChildControls()
End If
End Sub
D. Protected Overloads Overrides Function _
CreateControlCollection() As ControlCollection
Dim controls As New ControlCollection(Me)
Dim oFData As New OrderFormData("OrderForm")
controls.Add(oFData)
Return controls
End Function
Answer: A

29. You are creating a Windows Forms application for inventory management by using the .NET
Framework 3.5.
The application provides a form that allows users to maintain stock balances.
The form has the following features:
¡¤A dataset named dsStockBalance to store the stock informatio
¡¤A business component named scInvntory
The scInventory component provides a method named Save.
You need to ensure that only the modified stock balances of dsStockBalance are passed to the scInventory.Save method.
Which code segment should you use?
A. if(dsStockBalance.HasChanges())
dsStockBalance.AcceptChanges();
dsUpdates = dsStockBalance.GetChanges();
scInventory.Save(dsStockBalance);
B. if(dsStockBalance.HasChanges())
dsUpdates = dsStockBalance.GetChanges();
dsStockBalance.AcceptChanges();
scInventory.Save(dsStockBalance);
C. if(dsStockBalance.HasChanges())
{
dsStockBalance.AcceptChanges();
dsUpdates = dsStockBalance.GetChanges();
scInventory.Save(dsUpdates);
}
D. if(dsStockBalance.HasChanges())
{
dsUpdates = dsStockBalance.GetChanges();
dsStockBalance.AcceptChanges();
scInventory.Save(dsUpdates);
}
Answer: D

30. You are creating a Windows Forms application for inventory management by using the .NET Framework 3.5.
The application provides a form that allows users to maintain stock balances.
The form has the following features:
¡¤A dataset named dsStockBalance to store the stock informatio
¡¤A business component named scInventory
The scInventory component provides a method named Save.
You need to ensure that only the modified stock balances of dsStockBalance are passed to the scInventory.Save method.
Which code segment should you use?
A. If dsStockBalance.HasChanges() = True Then
dsStockBalance.AcceptChanges()
End If
dsUpdates = dsStockBalance.GetChanges()
scInventory.Save(dsStockBalance)
B. If dsStockBalance.HasChanges() = True Then
dsUpdates = dsStockBalance.GetChanges()
End If
dsStockBalance.AcceptChanges()
scInventory.Save(dsStockBalance)
C. If dsStockBalance.HasChanges() = True Then
dsStockBalance.AcceptChanges()
dsUpdates = dsStockBalance.GetChanges()
scInventory.Save(dsUpdates)
End If
D. If dsStockBalance.HasChanges() = True Then
dsUpdates = dsStockBalance.GetChanges()
dsStockBalance.AcceptChanges()
scInventory.Save(dsUpdates)
End If
Answer: D


© 2014 Cheat-Test.com, All Rights Reserved