Which code segment should you use?

You need to write a code segment that will add a string named strConn to the connection string
section of the application configuration file. Which code segment should you use?

You need to write a code segment that will add a string named strConn to the connection string
section of the application configuration file. Which code segment should you use?

A.
Configuration myConfig = ConfigurationManager.OpenExeConfiguration( ConfigurationUserLevel.None);
myConfig.ConnectionStrings.ConnectionStrings.Add( new ConnectionStringSettings(“ConnStr1”, strConn));
myConfig.Save();

B.
Configuration myConfig =ConfigurationManager.OpenExeConfiguration( ConfigurationUserLevel.None);
myConfig.ConnectionStrings.ConnectionStrings.Add( new ConnectionStringSettings(“ConnStr1”,strConn));
ConfigurationManager.RefreshSection( “ConnectionStrings”);

C.
ConfigurationManager.ConnectionStrings.Add( new ConnectionStringSettings(“ConnStr1”,strConn));
ConfigurationManager.RefreshSection( “ConnectionStrings”);

D.
ConfigurationManager.ConnectionStrings.Add( new ConnectionStringSettings(“ConnStr1”,strConn));
Configuration myConfig = ConfigurationManager.OpenExeConfiguration( ConfigurationUserLevel.None);
myConfig.Save();



Leave a Reply 2

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


seenagape

seenagape

I agree with the answer. A