p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Professional VB 2005 ISBN: 0-7645-7536-8 (http://p2p.wrox.com/forumdisplay.php?f=227)
-   -   Chapter 11 Code Examples (http://p2p.wrox.com/showthread.php?t=48790)

ablinco October 9th, 2006 03:56 AM

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?


All times are GMT -4. The time now is 09:49 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.