HowdoI Test for failed assignment to a ConnectionStringSettings object ?

Posted on 2008-11-06
Last Modified: 2013-11-26
I cannot figure out how to test for a "null" or empty value.

       Dim AppKey, AppValue As String
       Dim AppConnSettings As ConnectionStringSettings
       AppKey = "xxx.My.MySettings.Settingxx"
       AppConnSettings = ConfigurationManager.ConnectionStrings(AppKey)
       'How do I test that the above statement has anything in it?
       'Below gives me an error at design time that says
       '"Operator '=' is not defined for types 'System.Configuration.ConnectionStringSettings' and 'System.Configuration.ConnectionStringSettings'. "
       If AppConnSettings = Nothing Then
            Console.WriteLine("AppKey: {0}, has no connectionstringsetting", AppKey)
        End If

If I try something like string.isnullorempty(appconnsettings.tostring) that fails with a runtime null exception error.

How do I determine that appconnsettings failed to get a value from the assignment?
Question by:OuttaCyTE
    LVL 4

    Accepted Solution

    Try this:
    If AppConnSettings Is Nothing Then

    Author Comment


    You'd think that searching on the topic of null and nothing specifically with reference to .NET VB would have yielded a wealth of hits saying what you just did.

    But if they did, I was too stupid to read them correctly...

    Thanks again,
    LVL 4

    Expert Comment

    No worries

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (…
    More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    25 Experts available now in Live!

    Get 1:1 Help Now