Which connection string should you add to the Web.config file?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create a Microsoft
ASP.NET application. You want to connect the application to a Microsoft SQL Server Express 2008
database named MyDatabase. The primary database file is named MyDatabase.mdf and it is stored
in the App_Data folder. You need to define the connection string. Which connection string should
you add to the Web.config file?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create a Microsoft
ASP.NET application. You want to connect the application to a Microsoft SQL Server Express 2008
database named MyDatabase. The primary database file is named MyDatabase.mdf and it is stored
in the App_Data folder. You need to define the connection string. Which connection string should
you add to the Web.config file?

A.
Data Source=localhost; Initial Catalog=MyDataBase; Integrated Security=SSPI; User Instance=True

B.
Data Source=.\SQLEXPRESS; Initial Catalog=MyDataBase; Integrated Security=True; User
Instance=True

C.
Data Source=.\SQLEXPRESS; AttachDbFilename=|DataDirectory|\MyDatabase.mdf; Integrated
Security=True; User Instance=True

D.
Data Source=SQLEXPRESS; AttachDbFilename=|DataDirectory|\App_Data\MyDatabase.mdf;
Integrated Security=SSPI; User Instance=True

Explanation:
CHAPTER 2 ADO.NET Connected Classes
Lesson 1: Connecting to the Data Store
Attaching to a Local SQL Database File with SQL Express (page 73)



Leave a Reply 0

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