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

Posted on 2006-03-23
Medium Priority
Last Modified: 2010-04-23
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?

Question by:Richard Comito
LVL 52

Accepted Solution

Carl Tawn earned 1000 total points
ID: 16274593
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.
LVL 70

Assisted Solution

by:Éric Moreau
Éric Moreau earned 1000 total points
ID: 16274619
Hi GabicusC,

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


Author Comment

by:Richard Comito
ID: 16274671
Thanks carl_tawn and emoreau for your replys.

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month16 days, 7 hours left to enroll

850 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