Chapter 11 Code Examples
The following line in the GetPubsConnection function in the AdoNetFeaturesTest project is being flagged as obsolete.
ConfigurationSettings.AppSettings("dbConnectionStr ing")
I have checked the Online Help which indeed advises that:
This method is deprecated and is maintained for backward compatibility. Please use the GetSection method instead
Looking for GetSection in the help returns some code examples on its usage:
' Get a custom section.
Shared Sub GetSection()
Try
Dim customSection As CustomSection
' Get the current configuration file.
Dim config _
As System.Configuration.Configuration = _
ConfigurationManager.OpenExeConfiguration( _
ConfigurationUserLevel.None)
customSection = _
config.GetSection("CustomSection")
Console.WriteLine( _
"Section name: {0}", _
customSection.SectionInformation.Name)
Catch err As ConfigurationErrorsException
Console.WriteLine(err.ToString())
End Try
End Sub 'GetSection
This code does not seem to work for me, I get the following error - Type 'CustomeSection' is not defined.
Can anyone show how to return the connection string using GetSection?
|