Receiving a Function warning after converting for VS 2003 to VS 2005.

I am converting a project that I was working on in VS 2003 but after I converted this project to VS 2005 I get the following error:

"Function 'selAllOrgMembers' doesn't return a value on all code paths. A null reference exception could occur at run time when the result is used."

Here is the function.

    Public Function selAllOrgMembers() As SqlDataAdapter
            Dim cmdAllOrgMembers As New SqlCommand("selAllOrgMembers", objConn)
            cmdAllOrgMembers.CommandType = CommandType.StoredProcedure
            selAllOrgMembers = New SqlDataAdapter(cmdAllOrgMembers)
        Catch ex As SqlException
        End Try
    End Function

When I run this it works fine.  I am just trying to eliminate all the warnings I have and clean up my code.

How would I fix this warning that I am getting?

Richard ComitoDirector of ITAsked:
Who is Participating?
Carl TawnSystems and Integration DeveloperCommented:
Presumably it is because you do not have a return statement for your Catch block. You may just want to return null either in the catch block or after it as a default.
Éric MoreauSenior .Net ConsultantCommented:
Hi GabicusC,

You may add "return nothing" before the "end try"  

Richard ComitoDirector of ITAuthor Commented:
Thanks carl_tawn and emoreau for your replys.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.