RE: Function doesn't return a value on all code paths

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



a,

It looks like this function should really be a subprocedure.

Kerry Moorman


"a" wrote:

I have been cleaning up somebody else's code in Vs2005 .net 2.0

There wer lots of these code pat errors because of unitialized variables in
functions with Conditionals - that may or may not be set . These I have
cleaned up ok.

But I have a few like this one below.

The error is Function BindData doesn't return a value on all code paths
But I only see one code path. What am I missing?

Thanks

Bill

Private Function BindData(ByVal count As Integer, ByVal custID As Integer,
ByVal tempID As Integer, ByVal groupID As Integer)

cmd = New SqlCommand("stp_getPreparedMessages", con)

da.SelectCommand = cmd

da.SelectCommand.CommandType = CommandType.StoredProcedure

da.SelectCommand.parameters.addwithvalue("@int_rCount", pSize)

da.SelectCommand.parameters.addwithvalue("@int_UserGroupId", groupID)

da.SelectCommand.parameters.addwithvalue("@int_CustomerID", custID)

da.SelectCommand.parameters.addwithvalue("@int_UserIdAdd",
Session("userID"))

da.SelectCommand.parameters.addwithvalue("@sint_AccessLevel",
Session("accessLevel"))

da.SelectCommand.parameters.addwithvalue("@int_tempid", tempID)

da.SelectCommand.parameters.addwithvalue("@int_pageCount",
SqlDbType.Int).Direction = ParameterDirection.Output

da.Fill(ds, "tblPrepMsgs")

pCount = da.SelectCommand.Parameters("@int_pageCount").Value

dgPreparedMsgs.DataSource = ds.Tables("tblPrepMsgs")

dgPreparedMsgs.DataBind()

End Function



.



Relevant Pages

  • Re: Function doesnt return a value on all code paths
    ... paths But I only see one code path. ... Private Function BindData(ByVal count As Integer, ByVal custID As ... Integer, ByVal tempID As Integer, ByVal groupID As Integer) ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Function doesnt return a value on all code paths
    ... The error is Function BindData doesn't return a value on all code paths ... Private Function BindData(ByVal count As Integer, ByVal custID As Integer, ... ByVal tempID As Integer, ByVal groupID As Integer) ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Function doesnt return a value on all code paths
    ... Private Function BindData(ByVal count As Integer, ByVal custID As Integer, ByVal tempID As Integer, ByVal groupID As Integer) ...
    (microsoft.public.dotnet.languages.vb)
  • Function doesnt return a value on all code paths
    ... There wer lots of these code pat errors because of unitialized variables in ... Private Function BindData(ByVal count As Integer, ByVal custID As Integer, ... ByVal tempID As Integer, ByVal groupID As Integer) ...
    (microsoft.public.dotnet.languages.vb)