这是我的代码
<WebMethod()> _
Public Function getlocationsbypro(searchtype As String, crime As String, proid As String, startdate As String, enddate As String, starttime As String, endtime As String) As List(Of crimelocation)
If searchtype = "withdatetime" Then
Dim locs As New crimemsapslocationDataContext
Dim giveloc = From locations In locs.crimelocations _
Where locations.INCIDENTTYPE = crime And (locations.DATE_COMTD >= Convert.ToDateTime(startdate) And locations.DATE_COMTD <= Convert.ToDateTime(enddate)) _
And (locations.gettimecom >= starttime And locations.gettimecom <= endtime) _
Select locations
Return giveloc.ToList
ElseIf searchtype = "withdate" Then
Dim locs As New crimemsapslocationDataContext
Dim giveloc = From locations In locs.crimelocations _
Where locations.INCIDENTTYPE = crime And (locations.DATE_COMTD >= Convert.ToDateTime(startdate) And locations.DATE_COMTD <= Convert.ToDateTime(enddate)) _
Select locations
Return giveloc.ToList
ElseIf searchtype = "without" Then
Dim locs As New crimemsapslocationDataContext
Dim giveloc = From locations In locs.crimelocations _
Where locations.INCIDENTTYPE = crime _
Select locations
Return giveloc.ToList
End If
End Function
但是当我编译它时它说该函数没有在所有代码路径上返回一个值,尽管我的所有 if 语句都有一个 return 语句我错过了什么,而且我注意到如果没有 elseif 语句只是通常的 if else end它没有给我上述错误。