|
70-561
TS: Microsoft .NET Framework 3.5 ,
ADO.NET Application Development
This braindump is provided with ratings from different
students. I used www.examcheets.com study material and
the exam was not a problem for me.
QUESTION NO: 1
You work as an application developer at Abc.com. You
use Microsoft .NET Framework 3.5 and Microsoft ADO.NET
to develop an application. The Abc.com network contains
a Microsoft SQL Server 2005 server named ABC-DB01. Your
application retrieve records from a database named Abc_Trades
that resides on ABC-DB01. The application connects to
Abc_Trades by using an instance of the SqlConnection
class with the following connection string. "Data
Source=ABC-DB01;UID='mhamm;PWD=T35Abc1N9;"
However, when the application calls the Open method
of the SqlConnection object, it displays the following:
"Cannot open user default database. Login failed.
Login failed for user 'mhamm'".
You need to make sure that you can connect to Abc_Trades
when the user account for the connection is mhamm.
What should you do?
A. You should consider changing the connection string
as follows:
Data Source=ABC-DB01;Initial Catalog=Abc_Trades;UID=mhamm;
PWD=T35Abc1N9;"
B. You should consider creating a login for Mia Hamm
on ABC-DB01.
C. You should consider creating a database user object
in Abc_Trades and map the object to the SQL Server 2005
login of Mia Hamm.
D. You should consider changing the connection string
as follows:
"Server=ABC-DB01;Database=Abc_Trades;UID=mhamm;PWD=T35Abc1N9;"
Answer: C
QUESTION NO: 2
You work as an application developer at Abc.com. You
use Microsoft .NET Framework 3.5 and Microsoft ADO.NET
to develop an application that will connect to the Microsoft
SQL Server 2005 database. You application has the following
objects:
A SqlDataReader object named readerA SqlCommand object
named cmdRecordsA SqlCommand object named cmdUpdateA
SqlConnection object named conn Furthermore, the ConnectionString
property of the SqlConnection object is as follows:
"Server=ABC-DB01;Database=Abc.com;Integrated Security=SSPI"
To obtain the cmdRecords object, you should use the
reader object. Furthermore, the conn object is shared
by the cmdRecords and the cmdUpdate objects. You have
received instruction to make sure that that for each
record in the reader object, the application calls the
ExecuteNonQuery method of the cmdUpdate object.
What should you do?
A. You should consider changing the connection string
of conn to contain the following attribute. AsynchronousProcessing=true.
B. You should consider calling the InitializeLifeTimeService
method of conn.
C. You should consider changing the connection string
of conn to contain the following attribute.
MultipleActiveResultSets=true.
D. You should consider closing the conn after it was
called by the reader object, however, before calling
the cmdUpdate.ExecuteNonQuery() method, reopen conn.
Answer: C
QUESTION NO: 3
You work as an application developer at Abc.com. You
use Microsoft .NET Framework 3.5 and Microsoft ADO.NET
to develop an application that will connect to the Microsoft
SQL Server 2005 database. You have written the following
code to generate a storage schema definition for a stored
procedure from the database. <Function Name="Abc_GetSuppliersPerRegion"
Aggregate="false" BuiltIn="false"
NiladicFunction="false" IsComposable="false"
ParameterTypeSemantics="AllowImplicitConversion"
Schema="dbo">
<Parameter Name="region" Type="char"
Mode="In" />
</Function>
You application uses two namespaces named AbcModel.Store
and AbcModel.
Furthermore, the AbcModel.Store has the storage schema
and the AbcModel has the conceptual schema that has
an entity named Abc_Supplier. However, you were given
the instruction to create a function named Abc_GetSuppliersInRegion
that returns a list of Supplier entity instances.
What should you do? (Each correct answer presents part
of the solution. Choose TWO.)
A. You should consider creating the following code segment
in the conceptual schema:
<FunctionImport EntitySet="Abc_Supplier"
Name="Abc_GetSuppliersInRegion"
ReturnType="Collection(AbcModel.Supplier)">
<Parameter Name="region" Mode="In"
Type="String" />
</FunctionImport>
B. You should consider creating the following code segment
in the mapping schema:
<FunctionImportMapping FunctionImportName="GetSuppliers"
FunctionName="Abc.Model.Store.GetSuppliers">
<ResultMapping>
<EntityTypeMapping TypeName ="AbcModel.Supplier"
/>
</ResultMapping>
</FunctionImportMapping>
C. You should consider creating the following code segment
in the conceptual schema:
<FunctionImport EntitySet="Abc_Supplier"
Name="Abc_GetSuppliersInRegion"
ReturnType="AbcModel.Supplier">
<Parameter Name="region" Mode="In"
Type="String" />
</FunctionImport>
D. You should consider creating the following code segment
in the mapping schema:
<FunctionImportMapping FunctionImportName="GetSuppliers"
FunctionName="AbcModel.Store.GetSuppliers">
<ResultMapping>
<EntityTypeMapping TypeName="AbcModel.Supplier"
/>
</ResultMapping>
</FunctionImportMapping>
E. You should consider creating the following code segment
in the conceptual schema:
<FunctionImport EntitySet="Abc_Supplier"
Name="Abc_GetSuppliersInRegion"
ReturnType="Collection(AbcModel.Supplier)">
<Parameter Name="region" Mode="In"
Type="String" />
</FunctionImport>
F. You should consider creating the following code segment
in the mapping schema:
<FunctionImportMapping FunctionImportName="GetSuppliers"
FunctionName="AbcModel.Store.GetSuppliers">
<ResultMapping>
<EntityTypeMapping TypeName ="MultiSet"
/>
</ResultMapping>
</FunctionImportMapping>
Answer: A,B
QUESTION NO: 4
You work as an application developer at Abc.com. You
use Microsoft .NET Framework 3.5 and Microsoft ADO.NET
to develop an application that will connect to the Microsoft
SQL Server 2005 database. The application is used under
a Least-Privilege User Account (LUA) of the operating
system. You want to configure the SQL Server 2005 connection
string in the app.config file to use SQL Server Express
user instances. What should you do?
A. You should consider using the following code segment:
Data Source=\\SQLExpress;Integrated Security=true;User
Instance=true;AttachDBFilename=InstanceDB.mdf;Initial
Catalog=InstanceDB;
B. You should consider using the following code segment:
Data Source=\\SQLExpress;Integrated
Security=true;AttachDBFilename=|DataDirectory|\InstanceDB.mdf;Initial
Catalog=InstanceDB;
C. You should consider using the following code segment:
Data Source=\\SQLExpress;Integrated Security=true;User
Instance=true;AttachDBFilename=|DataDirectory|\InstanceDB.mdf;Initial
Catalog=InstanceDB;
D. You should consider using the following code segment:
Data Source=\\SQLExpress;Integrated Security=false;User
Instance=true;AttachDBFilename=|DataDirectory|\InstanceDB.mdf;Initial
Catalog=InstanceDB;
Answer: C
QUESTION NO: 5
You work as an application developer at Abc.com. You
use Microsoft .NET Framework 3.5 and Microsoft ADO.NET
to develop an application that will connect to the Microsoft
SQL Server 2005 database. Your application contains
the following code.
string queryString = "Select * from dbo.Abc_Users";
SqlCommand command = new SqlCommand(queryString, (SqlConnection)connection));
However, you want to get the value that is contained
in the first column of the first row of the result
set returned by the query.
What should you do?
A. You should consider adding the following code segment:
var value =command.ExecuteReader(CommandBehavior.SingleRow);string
requiredValue =
value[1].ToString();
B. You should consider adding the following code segment:
var value =command.ExecuteReader(CommandBehavior.SingleRow);string
requiredValue =
value[0].ToString();
C. You should consider adding the following code segment:
var value =command.ExecuteNonQuery();string requiredValue
= value.ToString();
D. You should consider adding the following code segment:
var value = command.ExecuteScalar();string requiredValue
= value.ToString();
Answer: D
QUESTION NO: 6
You work as an application developer at Abc.com. You
use Microsoft .NET Framework 3.5 and Microsoft ADO.NET
to develop an application that will connect to the Microsoft
SQL Server 2005 database. Your application contains
the following code.
01 DataTable dt = new DataTable();
02 dt.Columns.Add("number");
03 dt.Columns.Add("string");
04 dt.Rows.Add(1, "3");
05 dt.Rows.Add(2, "2");
06 dt.Rows.Add(3, "1");
07 var result = from p in dt.AsEnumerable()
08
09 foreach (var number in result) {
10 Console.Write(number.ToString());
11 }
However, you need to display the string "321".
What should you do?
A. You should consider adding the following code segment
at line 08:
orderby p["number"] select p["string"];
B. You should consider adding the following code segment
at line 08:
orderby p["string"] descending select p["number"];
C. You should consider adding the following code segment
at line 08:
orderby p["number"] descending select p["string"];
D. You should consider adding the following code segment
at line 08:
orderby p["string"] ascending select p["string"];
Answer: A
QUESTION NO: 7
You work as an application developer at Abc.com. You
use Microsoft .NET Framework 3.5 and Microsoft ADO.NET
to develop an application that will connect to the Microsoft
SQL Server 2005 database. The following contacts.xml
file is read by the developed application.
<contacts>
<contact contactId="2">
<firstName>Mia</firstName>
<lastName>Hamm</lastName>
</contact>
<contact contactId="3">
<firstName>Andy</firstName>
<lastName>Reid</lastName>
</contact>
<contact contactId="4">
<firstName>Amy</firstName>
<lastName>Walsh</lastName>
</contact>
</contacts>
Your application contains the following code. (Line
numbers are for reference only.)
01 XDocument loaded = XDocument.Load(@"D:\contacts.xml");
02
03 foreach (string name in q)
04 Console.WriteLine("{0}", name);
You were given the instruction to make sure that the
application outputs only the names Andy Reid and Amy
Walsh. What should you do?
A. You should consider adding the following code segment
at line 02:
var q = from c in loaded.Descendants("contact").Skip(1)select
(string)c.Element("firstName") + " "
+ (string)c.Element("lastName");
B. You should consider adding the following code segment
at line 02:
var q = from c in loaded.Descendants("contact")where
(int)c.Attribute("contactId") < 4select
(string)c.Element("firstName") + " "
+ (string)c.Element("lastName");
C. You should consider adding the following code segment
at line 02:
var q = from c in loaded.Descendants("contact").Skip(0)select
(string)c.Element("firstName") + " "
+ (string)c.Element("lastName");
D. You should consider adding the following code segment
at line 02:
var q = from c in loaded.Descendants("contact")where
c.IsAfter(c.FirstNode)select
(string)c.Element("firstName") + " "
+ (string)c.Element("lastName");
Answer: A
QUESTION NO: 8
You work as an application developer at Abc.com. You
use Microsoft .NET Framework 3.5 and Microsoft ADO.NET
to develop an application that will connect to the Microsoft
SQL Server 2005 database. Furthermore, the application
fills a DataSet object named Abc_cust with customer
records. Your application contains the following code.
(Line numbers are for reference only.)
01 System.IO.StreamWriter sw =
02 new System.IO.StreamWriter("Customers.xml");
03
04 sw.Close();
You have received instructions from management to write
the content of the Abc_cust object to the Customers.xml
file as XML data along with inline XML schema. What
should you do?
A. You should consider adding the following code segment
at line 03:
Abc_cust.WriteXml(sw);
B. You should consider adding the following code segment
at line 03:
sw.Write(Abc_cust.GetXmlSchema());
C. You should consider adding the following code segment
at line 03:
Abc_cust.WriteXml(sw, XmlWriteMode.WriteSchema);
D. You should consider adding the following code segment
at line 03:
sw.Write(Abc_cust.GetXml());
Answer: C
QUESTION NO: 9
You work as an application developer at Abc.com. You
use Microsoft .NET Framework 3.5 and Microsoft ADO.NET
to develop an application that will connect to the Microsoft
SQL Server 2005 database. Furthermore, the application
uses an XML file that contains product data. Furthermore,
a corresponding XSD file contains the schema of the
XML file. Management wants the application to do the
following: Loads the XML file in a typed DataSet and
validates it against the schema provided in the XSD
file. What should you do?
A. You should consider using the xsd.exe tool along
with the /loadxml parameter to create a typed DataSet
object that has the data from the XML file.
B. You should consider loading the XML file in an XmlDocument
object and validate method to validate the XML file
against the schema. Y6ou should also iterate through
the XML nodes of the XmlDocument object to create a
new typed DataRow for each node.
C. You should consider using the xsd.exe tool along
with the /dataset parameter to generate a typed DataSet
object and use the DataSet.ReadXml method to load the
typed DataSet object.
D. You should consider adding the XSD file to the schema
collections of the XmlReader object and load the XML
file in the XmlReader object. You should also iterate
through the XML nodes of the XMLReader object to create
a new typed DataRow for each node.
Answer: C
QUESTION NO: 10
You work as an application developer at Abc.com. You
use Microsoft .NET Framework 3.5 and Microsoft ADO.NET
to develop an application. The user name and password
that is kept by the connection string is stored directly
in the code of the application. However, you want to
make sure that the password in the connection string
is as protected. What should you do?
A. You should consider adding the connection string
to the Settings.settings file.
B. You should consider adding connection string to the
Web.config file and use protected configuration.
C. You should consider using the TRUE setting in the
Persist Security Info keyword.
D. You should consider using the FALSE setting in the
Persist Security Info keyword
Answer: B
QUESTION NO: 11
You work as an application developer at Abc.com. You
use Microsoft .NET Framework 3.5 and Microsoft ADO.NET
to develop an application. The database on the Microsoft
SQL Server 2005 database has two tables that are displayed
by using two SqlConnection objects in two different
GridView controls. However, management wants the tables
to be displayed at the same time with the use a single
SqlConnection object. What should you do?
A. You should consider creating a bound connection by
using the sp_getbindtoken and the sp_bindsession stored
procedures.
B. You should consider creating an exception handler
for the connection-busy exception that is thrown on
using a single SqlConnection object.
C. You should consider running the two SqlDataReader
objects by using a single SqlCommand object.
D. You should consider enabling Multiple Active Result
Sets (MARS) in the connection string of the application.
Answer: D
QUESTION NO: 12
You work as an application developer at Abc.com. You
use Microsoft .NET Framework 3.5 and Microsoft ADO.NET
to develop an application that will connect to the Microsoft
SQL Server 2005 database. You then define the connection
string of the application as follows:
"Server=Prod;Database=WingtipToys;Integrated Security=SSPI;Asynchronous
Processing=true"
Furthermore, the following code segment is used on the
application: (Line numbers are included for reference
only.)
01 protected void UpdateData(SqlCommand cmd) {
02 cmd.Connection.Open();
03
04 lblResult.Text = "Updating ...";
05 }
You discover that the cmd object takes a long time to
execute. You were given the instruction to make sure
that the application continues to execute while cmd
is executing. What should you do?
A. You should consider adding the following code segment
at line 03:
cmd.BeginExecuteNonQuery(new AsyncCallback(UpdateComplete),
cmd);
B. You should consider adding the following code segment:
private void UpdateComplete (IAsyncResult ar) { int
count = (int)ar.AsyncState;
LogResults(count);}
C. You should consider adding the following code segment
at line 03:
SqlNotificationRequest notification =new SqlNotificationRequest("UpdateComplete",
"",
10000);cmd.Notification = notification;cmd.ExecuteNonQuery();
D. You should consider adding the following code segment:
private void UpdateComplete(SqlNotificationRequest notice)
{ int count =
int.Parse(notice.UserData); LogResults(count);}
E. You should consider adding the following code segment:
private void UpdateComplete (IAsyncResult ar) { SqlCommand
cmd =
(SqlCommand)ar.AsyncState; int count = cmd.EndExecuteNonQuery(ar);
LogResults(count);}
F. You should consider adding the following code segment
at line 03:
cmd.StatementCompleted +=new
StatementCompletedEventHandler(UpdateComplete);cmd.ExecuteNonQuery();
G. You should consider adding the following code segment:
private void UpdateComplete (object sender, StatementCompletedEventArgs
e) { int count =e.RecordCount; LogResults(count);}
Answer: A,E
QUESTION NO: 13
You work as an application developer at Abc.com. You
use Microsoft .NET Framework 3.5 and Microsoft ADO.NET
to develop an application that will connect to the Microsoft
SQL Server 2005 database. You have completed the following
code segment. (Line numbers are for reference only.)
01 public IDataReader GetCustomerReader()
02 {
03 SqlConnection con = new SqlConnection();
04 //Set up the connection
05 con.Open();
06 string sql = "Select * from Customers";
07 IDataReader rd = null;
08
09 con.Close();
10 return rd;
11 }
You have received instructions to make sure that a DataReader
stream for the data in the Customers table can be returned
from the GetCustomerReader method. What should you do?
A. You should consider using the following code segment
in line 08:
SqlDataAdapter adp = new SqlDataAdapter(sql, con);
DataSet ds = new DataSet();
adp.FillSchema(ds, SchemaType.Source, "Customers");
rd = ds.Tables["Customers"].CreateDataReader();
B. You should consider using the following code segment
in line 08:
SqlDataAdapter adp = new SqlDataAdapter(sql, con);
DataSet ds = new DataSet();
adp.Fill(ds);
rd = ds.CreateDataReader();
C. You should consider using the following code segment
in line 08:
SqlCommand cmd = new SqlCommand(sql, con);
rd = cmd.ExecuteReader(CommandBehavior.CloseConnection);
D. You should consider using the following code segment
in line 08:
SqlCommand cmd = new SqlCommand(sql, con);
rd = cmd.ExecuteReader(CommandBehavior.SingleResult);
Answer: B
70-561
|