You create a Microsoft ASP.NET application by using the Microsoft .NET Framework
version 3.5.You add a Web page named HomePage.aspx in the application. The Web page
contains different controls.You add a newly created custom control named CachedControl to
the Web page. You need to ensure that the following requirements are met:
The custom control state remains static for one minute.
The custom control settings do not affect the cache settings of other elements in the Web page.
What should you do?
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?
You create an application by using the Microsoft .NET Framework 3.5 and Microsoft
ADO.NET.You write the following code segment. (Line numbers are included for reference
only.)
01 private List GetEmployers() {
02 List employers = new List();
03 SqlCommand cmd = new SqlCommand();
04 ...
05 XmlReader reader = cmd.ExecuteXmlReader();
06 while (reader.Read()) {
07
08 }
09 return employers;
10 }
The cmd object returns the following XML data structure.
ShaiBassliWingtip Toys
...
...
You need to populate the employers list with each employer entry in the XML data
structure.
Which code segment should you insert at line 07?
You are creating a Windows Forms application by using the .NET Framework 3.5. The
application requires a thread that accepts a single integer parameter.You write the following
code segment. (Line numbers are included for reference only.)
01 Thread myThread = new Thread(new
ParameterizedThreadStart(DoWork));
02 myThread.Start(100);
03 ...
You need to declare the method signature of the DoWork method. Which method signature
should you use?
You create a Microsoft ASP.NET application by using the Microsoft .NET Framework
version 3.5.You write the following code segment to create a client-script function. (Line
numbers are included for reference only.)
01 function updateLabelControl(labelId, newText) {
02 var label = $find(labelId);
03 label.innerHTML = newText;
04 }
The client script function uses ASP.NET AJAX and updates the text of any Label control in
the Web form.When you test the client script function, you discover that the Label controls
are not updated. You receive the following JavaScript error message in the browser: "'null' is
null or not an object." You need to resolve the error.What should you do?
You create an application by using the Microsoft .NET Framework 3.5 and Microsoft
ADO.NET. The application uses a Microsoft SQL Server 2005 database. To open a
connection to the database, you write the following code segment. (Line numbers are
included
for reference only.)
01 private void GetOpenOrders() {
02 try {
03 //open SqlConnection and execute command.
04 }
05 catch (SqlException exp) {
06
07 }
08 }
The connection generates error messages and raises an exception. You use a ListBox control
named lstResults to display the error messages.You need to add a list item in the lstResults
control for each connection-related error message returned by the SqlConnection object.
What should you do?
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?
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 reference 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?
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?
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 String myConnString = "User
02 ID=;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?