J
John Walker
Hi, Is there a way to dynamically get the name of the current Sub?
In my code below in the exception "catch" i write the name of the Sub to the
error log so that i will know where there error happened, but since i reuse
this code in other Subs i sometimes forget to change the name of the Sub. is
there a way to get it dynamically?
Also, is there a way to write out the line number where the error happened
so you can pinpoint exactly where the error occurred?
And if anyone has any suggestions for any other useful information which i
can write to the error log, i'd appreciate it.
Thanks, John
Private Sub subGetTruckerCodes( _
ByRef argDS As DataSet _
)
Try
If sqlConnect.State = ConnectionState.Closed Then
sqlConnect.Open()
End If
sqlConnect.ChangeDatabase("AccountManage")
Dim dad As New SqlDataAdapter("spGetProfileTruckerCodes", sqlConnect)
dad.SelectCommand.CommandType = CommandType.StoredProcedure
dad.SelectCommand.CommandTimeout = 120
Dim ds As New DataSet
dad.Fill(ds)
Catch ex As Exception
Log.Error("subGetTruckerCodes")
Log.Error(ex.Message)
End Try
End Sub
In my code below in the exception "catch" i write the name of the Sub to the
error log so that i will know where there error happened, but since i reuse
this code in other Subs i sometimes forget to change the name of the Sub. is
there a way to get it dynamically?
Also, is there a way to write out the line number where the error happened
so you can pinpoint exactly where the error occurred?
And if anyone has any suggestions for any other useful information which i
can write to the error log, i'd appreciate it.
Thanks, John
Private Sub subGetTruckerCodes( _
ByRef argDS As DataSet _
)
Try
If sqlConnect.State = ConnectionState.Closed Then
sqlConnect.Open()
End If
sqlConnect.ChangeDatabase("AccountManage")
Dim dad As New SqlDataAdapter("spGetProfileTruckerCodes", sqlConnect)
dad.SelectCommand.CommandType = CommandType.StoredProcedure
dad.SelectCommand.CommandTimeout = 120
Dim ds As New DataSet
dad.Fill(ds)
Catch ex As Exception
Log.Error("subGetTruckerCodes")
Log.Error(ex.Message)
End Try
End Sub