PsychoCoder
Programmer
In my application I have the following function:
This function is called in a seperate function:
But when the code is ran the GetGMTOffset jumps straight to the Catch exSQL As SqlException
MsgBox(SQL_EXCEPTION, MsgBoxStyle.Critical, "Database Error") line. Am I not using ExecuteScalar correctly?
Any ideas?
Senior Qik III, ASP.Net, VB.Net ,SQL Programmer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Code:
Public Function GetGMTOffset(ByVal sAirport As String) As Double
Dim dOffset As Double
sSQL = "EXECUTE ama_GetGMTOffset "
cmdCommand = New SqlCommand(sSQL, cnConnection)
cmdCommand.Parameters.AddWithValue("@airport", sAirport)
Try
cnConnection.Open()
dOffset = cmdCommand.ExecuteScalar
Return dOffset
Catch exSQL As SqlException
MsgBox(SQL_EXCEPTION, MsgBoxStyle.Critical, "Database Error")
Catch exSQLTimeout As TimeoutException
MsgBox(SQL_TIMEOUT, MsgBoxStyle.Critical, "Timeout Error")
Catch exApp As ApplicationException
MsgBox(APP_EXCEPTION, MsgBoxStyle.Critical, "Application Error")
Catch ex As Exception
MsgBox(GENERAL_EXCEPTION & ex.Message, MsgBoxStyle.Critical, "General Error")
Finally
cnConnection.Close()
End Try
End Function
This function is called in a seperate function:
Code:
Public Function ConvertGMT(ByVal dLocalDate As DateTime, ByVal sAirport As String) As DateTime
_dGMTTime = DateAdd(DateInterval.Hour, CType(GetGMTOffset(sAirport), Double), dLocalDate)
Return _dGMTTime
End Function
But when the code is ran the GetGMTOffset jumps straight to the Catch exSQL As SqlException
MsgBox(SQL_EXCEPTION, MsgBoxStyle.Critical, "Database Error") line. Am I not using ExecuteScalar correctly?
Any ideas?
Senior Qik III, ASP.Net, VB.Net ,SQL Programmer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"In the new millennium there will be two kinds of business; those on the net and those out of business"
~ Bill Gates ~