Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27554

VS 2010 Function does not return a value on all code paths.

$
0
0
Just wondering what the proper syntax would be for something like this so it does not return the error above:

Code:

Function DlookUp_In_Access(ByVal strLookUpFieldName As String, _
                                  ByVal strTableName As String, _
                                  ByVal Critera As String)
        Dim con As OleDbConnection
        Try
            con = New OleDbConnection(cs)
            Dim dbCmd As OleDbCommand = New OleDbCommand("select " & strLookUpFieldName & " from " & strTableName & _
                          " WHERE " & Critera, con)
            con.Open()
            'MessageBox.Show(dbCmd.ExecuteScalar().ToString)
            Return dbCmd.ExecuteScalar().ToString
            con.Close()
        Catch ex As Exception
            Dim el As New ErrorLogger
            el.WriteToErrorLog(ex.Message, ex.StackTrace, "Error")
        End Try
    End Function

Thanks
LB

Viewing all articles
Browse latest Browse all 27554

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>