Microsoft TS: Accessing Data with Microsoft .NET Framework 4 - 070-516 FREE EXAM DUMPS QUESTIONS & ANSWERS
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application.
The application connects to a Microsoft SQL Server 2008 database.
You need to use a spatial value type as a parameter for your database query. What should you do?
The application connects to a Microsoft SQL Server 2008 database.
You need to use a spatial value type as a parameter for your database query. What should you do?
Correct Answer: B
Vote an answer
Explanation: Only visible for FreeCram members. You can sign-up / login (it's free).
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application.
The application connects to a Microsoft SQL Server database.
The Data Definition Language (DDL) script of the database contains the following code segment:
CREATE TABLE [Sales].[SalesOrderHeader]( [SalesOrderID] [int] IDENTITY(1,1) NOT NULL, [BillToAddressID] [int] NOT NULL, ... CONSTRAINT [PK_SalesOrderHeader_SalesOrderID] PRIMARY KEY CLUSTERED ([SalesOrderID] ASC) )
ALTER TABLE [Sales].[SalesOrderHeader] WITH CHECK ADD CONSTRAINT [FK_SalesOrderHeader_Address] FOREIGN KEY([BilIToAddressID]) REFERENCES [Person].[Address]([AddressID])
You create an ADO.NET Entity Framework model. You need to ensure that the entities of the model
correctly map to the DDL of the database.
What should your model contain?


The application connects to a Microsoft SQL Server database.
The Data Definition Language (DDL) script of the database contains the following code segment:
CREATE TABLE [Sales].[SalesOrderHeader]( [SalesOrderID] [int] IDENTITY(1,1) NOT NULL, [BillToAddressID] [int] NOT NULL, ... CONSTRAINT [PK_SalesOrderHeader_SalesOrderID] PRIMARY KEY CLUSTERED ([SalesOrderID] ASC) )
ALTER TABLE [Sales].[SalesOrderHeader] WITH CHECK ADD CONSTRAINT [FK_SalesOrderHeader_Address] FOREIGN KEY([BilIToAddressID]) REFERENCES [Person].[Address]([AddressID])
You create an ADO.NET Entity Framework model. You need to ensure that the entities of the model
correctly map to the DDL of the database.
What should your model contain?


Correct Answer: B
Vote an answer
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application.
You create a stored procedure to insert a new record in the Categories table according to following code
segment.
CREATE PROCEDURE dbo.InsertCategory @CategoryName navrchar(15),
@Identity int OUT
AS INSERT INTO Categories(CategoryName) VALUES (@CategoryName) SET @Identity = SCOPE_IDENTITY() RETURN @@ROWCOUNT
You add the following code fragment. (Line numbers are included for reference only.)
01 private static void ReturnIdentity(string connectionString)
02 {
03 using(SqlConnection connection = new SqlConnection(connectionString))
04 {
05 SqlDataAdpater adapter = new SqlDataAdapter("SELECT CategoryID,
CategoryName FROM dbo.Categories", connection);
06 adapter.InsertCommand = new SqlCommand("InsertCategory", connection);
07 adapter.InsertCommand.CommandType = CommandType.StoredProcedure;
08 SqlParameter rowcountParameter = adapter.InsertCommand.Parameters.Add
("@RowCount", SqlDbType.Int);
09 ...
10 adapter.InsertCommand.Parameters.Add("@CategoryName", SqlDbType.NChar,
15, "CategoryName");
11 SqlParameter identityParameter = adapter.InsertCommand.Parameters.Add
("@Identity", SqlDbType.Int, 0, "CategoryID");
12 ...
13 DataTable categories = new DataTable();
14 adapter.Fill(categories);
15 DataRow ctegoryRow = categories.NewRow();
16 categoryRow["CategoryName"] = "New beverages";
17 categories.Rows.Add(categoryRow);
18 adapter.Update(categories);
19 Int32 rowCount = (Int32)adapter.InsertCommand.Parameters
["@RowCount"].Value;
20 }
21 }
Which code elements needs to be added in the empty lines?
You create a stored procedure to insert a new record in the Categories table according to following code
segment.
CREATE PROCEDURE dbo.InsertCategory @CategoryName navrchar(15),
@Identity int OUT
AS INSERT INTO Categories(CategoryName) VALUES (@CategoryName) SET @Identity = SCOPE_IDENTITY() RETURN @@ROWCOUNT
You add the following code fragment. (Line numbers are included for reference only.)
01 private static void ReturnIdentity(string connectionString)
02 {
03 using(SqlConnection connection = new SqlConnection(connectionString))
04 {
05 SqlDataAdpater adapter = new SqlDataAdapter("SELECT CategoryID,
CategoryName FROM dbo.Categories", connection);
06 adapter.InsertCommand = new SqlCommand("InsertCategory", connection);
07 adapter.InsertCommand.CommandType = CommandType.StoredProcedure;
08 SqlParameter rowcountParameter = adapter.InsertCommand.Parameters.Add
("@RowCount", SqlDbType.Int);
09 ...
10 adapter.InsertCommand.Parameters.Add("@CategoryName", SqlDbType.NChar,
15, "CategoryName");
11 SqlParameter identityParameter = adapter.InsertCommand.Parameters.Add
("@Identity", SqlDbType.Int, 0, "CategoryID");
12 ...
13 DataTable categories = new DataTable();
14 adapter.Fill(categories);
15 DataRow ctegoryRow = categories.NewRow();
16 categoryRow["CategoryName"] = "New beverages";
17 categories.Rows.Add(categoryRow);
18 adapter.Update(categories);
19 Int32 rowCount = (Int32)adapter.InsertCommand.Parameters
["@RowCount"].Value;
20 }
21 }
Which code elements needs to be added in the empty lines?
Correct Answer: B
Vote an answer
Explanation: Only visible for FreeCram members. You can sign-up / login (it's free).
You use Microsoft .NET Framework 4.0 to develop an application that connects to a local Microsoft SQL
Server 2008 database.
The application can access a high-resolution timer. You need to display the elapsed time, in sub-
milliseconds (<1 millisecond),
that a database query takes to execute. Which code segment should you use?
Server 2008 database.
The application can access a high-resolution timer. You need to display the elapsed time, in sub-
milliseconds (<1 millisecond),
that a database query takes to execute. Which code segment should you use?
Correct Answer: B
Vote an answer
Explanation: Only visible for FreeCram members. You can sign-up / login (it's free).
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application. The application contains following XML document.
<feed> <title>Products</title> <entry>
<title>Entry title 1</title>
<author>Author 1</author>
<content>
<properties>
<description>some description</description>
<notes>some notes</notes>
<comments>some comments</comments>
</properties>
</content>
</entry>
...
</feed>
You plan to add localization features to the application. You add the following code segment. (Line numbers are included for reference only.)
01 public IEnumerable <XNode> GetTextNodesForLocalization(XDocument doc) 02 {
03 ...
04 return from n in nodes
05 where n.NodeType = XmlNodeType.Text
06 select n;
07 }
You need to ensure that the GetTextNodeForLocalization method returns all the XML text nodes of the XML
document.
Which code segment should you inser at line 03?
<feed> <title>Products</title> <entry>
<title>Entry title 1</title>
<author>Author 1</author>
<content>
<properties>
<description>some description</description>
<notes>some notes</notes>
<comments>some comments</comments>
</properties>
</content>
</entry>
...
</feed>
You plan to add localization features to the application. You add the following code segment. (Line numbers are included for reference only.)
01 public IEnumerable <XNode> GetTextNodesForLocalization(XDocument doc) 02 {
03 ...
04 return from n in nodes
05 where n.NodeType = XmlNodeType.Text
06 select n;
07 }
You need to ensure that the GetTextNodeForLocalization method returns all the XML text nodes of the XML
document.
Which code segment should you inser at line 03?
Correct Answer: B
Vote an answer
Explanation: Only visible for FreeCram members. You can sign-up / login (it's free).
You need to ensure that an exception is thrown when color names are set to less than two characters. What should you do?
Correct Answer: C
Vote an answer
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?
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?
Correct Answer: B
Vote an answer
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create a Microsoft ASP.NET
application.
The application connects to a Microsoft SQL Server database. The application is hosted on a Web server
along with other applications.
You need to secure the transmission of data between the application and the database.
You need to achieve this goal without affecting other applications. What should you do?
application.
The application connects to a Microsoft SQL Server database. The application is hosted on a Web server
along with other applications.
You need to secure the transmission of data between the application and the database.
You need to achieve this goal without affecting other applications. What should you do?
Correct Answer: C
Vote an answer
Explanation: Only visible for FreeCram members. You can sign-up / login (it's free).
You use Microsoft Visual Studio 2010 and Microsoft ADO.NET Framework 4.0 to create an application.
The application connects to a Microsoft SQL Server 2008 database.
You use the ADO.NET LINQ to SQL model to retrieve data from the database. You use stored procedures
to return multiple result sets.
You need to ensure that the result sets are returned as strongly typed values. What should you do?
The application connects to a Microsoft SQL Server 2008 database.
You use the ADO.NET LINQ to SQL model to retrieve data from the database. You use stored procedures
to return multiple result sets.
You need to ensure that the result sets are returned as strongly typed values. What should you do?
Correct Answer: C
Vote an answer
Explanation: Only visible for FreeCram members. You can sign-up / login (it's free).