S
Screaming Eagles 101
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.
This is the Warning
Function 'GetData' doesn't return a value on all code paths. A null
reference exception could occur at run time when the result is used.
and this is the code:
Public Function GetData(ByVal ConnectionType As String, ByVal
ConnectionString As String, ByVal strQuery As String) As DataTable
Try
GetData = New DataTable
If ConnectionType = "SQL" Then
Dim da As SqlDataAdapter
da = New SqlDataAdapter(strQuery, ConnectionString)
da.Fill(GetData)
Else
Dim da As OdbcDataAdapter
da = New OdbcDataAdapter(strQuery, ConnectionString)
da.Fill(GetData)
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Function
--
Filip
http://users.skynet.be/101airborne
Official Site of the 101st Airborne - 463rd PFA
skype: airborne463pfa-fiwi
-------------------------------------------------
best way,
maybe one of you can help.
Application is running smoothly, it's only a warning, but I'd like to
resolve it.
This is the Warning
Function 'GetData' doesn't return a value on all code paths. A null
reference exception could occur at run time when the result is used.
and this is the code:
Public Function GetData(ByVal ConnectionType As String, ByVal
ConnectionString As String, ByVal strQuery As String) As DataTable
Try
GetData = New DataTable
If ConnectionType = "SQL" Then
Dim da As SqlDataAdapter
da = New SqlDataAdapter(strQuery, ConnectionString)
da.Fill(GetData)
Else
Dim da As OdbcDataAdapter
da = New OdbcDataAdapter(strQuery, ConnectionString)
da.Fill(GetData)
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Function
--
Filip
http://users.skynet.be/101airborne
Official Site of the 101st Airborne - 463rd PFA
skype: airborne463pfa-fiwi
-------------------------------------------------