What should you do?

You create Microsoft Windows-based applications. You are creating an application that will connect to a Microsoft SQL Server 2005 database. You write the following code segment for a method contained in the application. (Line numbers are included for reference only.)

01 private SqlConnection cn;
02 public frmMain() {
03 InitializeComponent();
04 cn = new SqlConnection(“data source = localhost;initial Catalog = Accounting;integrated security = true”);
05 }

In the production environment, the database will be stored by a server on the network. You need to eliminate the requirement to recompile the application when you deploy it to the production environment. You want to achieve this by using minimum amount of programming effort. What should you do?

You create Microsoft Windows-based applications. You are creating an application that will connect to a Microsoft SQL Server 2005 database. You write the following code segment for a method contained in the application. (Line numbers are included for reference only.)

01 private SqlConnection cn;
02 public frmMain() {
03 InitializeComponent();
04 cn = new SqlConnection(“data source = localhost;initial Catalog = Accounting;integrated security = true”);
05 }

In the production environment, the database will be stored by a server on the network. You need to eliminate the requirement to recompile the application when you deploy it to the production environment. You want to achieve this by using minimum amount of programming effort. What should you do?

A.
Create an application configuration file to store the connection string. Change the code to read the connection string from the configuration file.

B.
Create an XML file in the application folder to store the connection string. Change the code to use an XMLReader object to connect to a file stream and read the connection string.

C.
Create a component that returns the connection string. Change the code to use the component to get the connection string.

D.
Create a text file to store the connection string. Change the code to use a TextReader object to connect to a file stream and read the connection string.



Leave a Reply 0

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