Richard Comito
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("selAllOrgMembe rs", objConn)
cmdAllOrgMembers.CommandTy pe = CommandType.StoredProcedur e
objConn.Open()
cmdAllOrgMembers.ExecuteNo nQuery()
objConn.Close()
selAllOrgMembers = New SqlDataAdapter(cmdAllOrgMe mbers)
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
"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("selAllOrgMembe
cmdAllOrgMembers.CommandTy
objConn.Open()
cmdAllOrgMembers.ExecuteNo
objConn.Close()
selAllOrgMembers = New SqlDataAdapter(cmdAllOrgMe
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
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER