Link to home
Start Free TrialLog in
Avatar of Richard Comito
Richard ComitoFlag for United States of America

asked on

Receiving a Function warning after converting VB.net 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
        Try
            Dim cmdAllOrgMembers As New SqlCommand("selAllOrgMembers", objConn)
            cmdAllOrgMembers.CommandType = CommandType.StoredProcedure
            objConn.Open()
            cmdAllOrgMembers.ExecuteNonQuery()
            objConn.Close()
            selAllOrgMembers = New SqlDataAdapter(cmdAllOrgMembers)
        Catch ex As SqlException
            MsgBox(ex.Message)
        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?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Richard Comito

ASKER

Thanks carl_tawn and emoreau for your replys.