473,387 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Function doesn't return a value on all code paths

a
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_rCo unt", pSize)

da.SelectCommand.parameters.addwithvalue("@int_Use rGroupId", groupID)

da.SelectCommand.parameters.addwithvalue("@int_Cus tomerID", custID)

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

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

da.SelectCommand.parameters.addwithvalue("@int_tem pid", tempID)

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

da.Fill(ds, "tblPrepMsgs")

pCount = da.SelectCommand.Parameters("@int_pageCount").Valu e

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

dgPreparedMsgs.DataBind()

End Function
Aug 2 '06 #1
4 2123
md
From what I see, you're not returning any value at all. Also, if you have
Option strict on full it will complain (as a warning I think) that you don't
specify a type for the function.

Matt
"a" <aa@ss.comwrote in message
news:bi****************@tornado.tampabay.rr.com...
>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_rCo unt", pSize)

da.SelectCommand.parameters.addwithvalue("@int_Use rGroupId", groupID)

da.SelectCommand.parameters.addwithvalue("@int_Cus tomerID", custID)

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

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

da.SelectCommand.parameters.addwithvalue("@int_tem pid", tempID)

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

da.Fill(ds, "tblPrepMsgs")

pCount = da.SelectCommand.Parameters("@int_pageCount").Valu e

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

dgPreparedMsgs.DataBind()

End Function


Aug 2 '06 #2
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_rCo unt", pSize)

da.SelectCommand.parameters.addwithvalue("@int_Use rGroupId", groupID)

da.SelectCommand.parameters.addwithvalue("@int_Cus tomerID", custID)

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

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

da.SelectCommand.parameters.addwithvalue("@int_tem pid", tempID)

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

da.Fill(ds, "tblPrepMsgs")

pCount = da.SelectCommand.Parameters("@int_pageCount").Valu e

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

dgPreparedMsgs.DataBind()

End Function
Aug 2 '06 #3
"a" <aa@ss.comschrieb:
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?

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_rCo unt", pSize)

da.SelectCommand.parameters.addwithvalue("@int_Use rGroupId", groupID)

da.SelectCommand.parameters.addwithvalue("@int_Cus tomerID", custID)

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

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

da.SelectCommand.parameters.addwithvalue("@int_tem pid", tempID)

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

da.Fill(ds, "tblPrepMsgs")

pCount = da.SelectCommand.Parameters("@int_pageCount").Valu e

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

dgPreparedMsgs.DataBind()

End Function
The function neither contains a 'Return <value>' statement nor does it
contain an assignment to the function name. Thus you may want to replace
the 'Function' with 'Sub'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Aug 2 '06 #4
Hello a,

You could instead create a collection that disallowed adding non-unique values.

Public Class UniqueStringList
Inherits List(Of String)
Public Shadows Sub Add(ByVal tValue As String)

If Not Me.Contains(tValue) Then
MyBase.Add(tValue)
End If

End Sub

End Class

-Boo
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_rCo unt", pSize)

da.SelectCommand.parameters.addwithvalue("@int_Use rGroupId", groupID)

da.SelectCommand.parameters.addwithvalue("@int_Cus tomerID", custID)

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

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

da.SelectCommand.parameters.addwithvalue("@int_tem pid", tempID)

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

da.Fill(ds, "tblPrepMsgs")

pCount = da.SelectCommand.Parameters("@int_pageCount").Valu e

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

dgPreparedMsgs.DataBind()

End Function

Aug 4 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my...
3
by: Nenad Dobrilovic | last post by:
Hi, I have function which is throwning exception, like this: public class LoggedException : Exception { public void Throw() { throw this; } }
5
by: Andy Sutorius | last post by:
Hi, I am attempting to convert this vb function to csharp but I am getting stuck on the if statement dt.Rows(iLoop)("FAQCategoryID")). The compiler says "method name expected" and underlines...
5
by: Dmitriy Lapshin [C# / .NET MVP] | last post by:
Hi all, I think the VB .NET compiler should at least issue a warning when a function does not return value. C# and C++ compilers treat this situation as an error and I believe this is the right...
5
by: Rob Meade | last post by:
Hi all, Quick question if I may... I have a function which depending on whether it was succesful to do something or not returns True or False as a boolean. I have another function which...
6
by: Screaming Eagles 101 | last post by:
Hi, I got this warning, but I don't have a clue on how to resolve it the best way, maybe one of you can help. Application is running smoothly, it's only a warning, but I'd like to resolve it. ...
27
by: Terry | last post by:
I am getting the following warning for the below function. I understand what it means but how do I handle a null reference? Then how do I pass the resulting value? Regards Warning 1...
3
by: sony.m.2007 | last post by:
Hi, I’m new to ASP.NET I have written a function with a return value. If the arguments to the functions are invalid means I’m giving exit(0) Else means do some process and return a value. When...
12
by: hectorchu | last post by:
Why doesn't my compiler (g++) flag something like this as an error: int main() { } ?
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.