Which line of code should you use?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application.
The configuration file contains the following code segment.

<configuration>
<connectionStrings>
<add name=”AdventureWorksLT”
connectionString=”DataSource=SQL01;InitialCatalog=AdventureWorksLT;IntegratedSecurity=True;”
providerName=”System.Data.SqlClient”/>
</connectionStrings>
</configuration>

You need to retrieve the connection string named AdventureWorksLT from the configuration file. Which line of code should you use?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application.
The configuration file contains the following code segment.

<configuration>
<connectionStrings>
<add name=”AdventureWorksLT”
connectionString=”DataSource=SQL01;InitialCatalog=AdventureWorksLT;IntegratedSecurity=True;”
providerName=”System.Data.SqlClient”/>
</connectionStrings>
</configuration>

You need to retrieve the connection string named AdventureWorksLT from the configuration file. Which line of code should you use?

A.
varconnectionString=ConfigurationManager.ConnectionStrings[“AdventureWorksLT”].ConnectionString;

B.
varconnectionString=ConfigurationManager.ConnectionStrings[“AdventureWorksLT”].Name;

C.
varconnectionString=ConfigurationManager.AppSettings[“AdventureWorksLT”];

D.
varconnectionString=ConfigurationSettings.AppSettings[“AdventureWorksLT”];



Leave a Reply 0

Your email address will not be published. Required fields are marked *