I have a strange problem. Probably there is a reason but I cannot get it.
I was asked by my client to develop a custom logger to database. It should be very simple and it is very simple.
I also created the table CCC_Logs to store the records.
The Logger I developed is an Vbnet object, it has a property (among the others) that is the Connection of type IConnection and a method (among the others) that is “WriteLog(…)”
Public Class CCC_Logs
Private Property Connection As IConnection
Public Sub New(ByRef connection As IConnection)
Me.Connection = connection
Public Sub WriteLog(ByVal ccc_ Message as string)
Dim logRecord As ISingleDbObject = Me.Connection.CreateSingle("CCC_Logs")
logRecord ("CCC_Message").NewValue = ccc_Message
The idea is to instantiate the object Logger passing the Connection and then call the method WriteLog to persist the info on the database. It works VERY WELL but it stops working if I try to log something into a catch section. I mean, if I do this:
Public sub xxxx()
Dim logger As CCC_Logs = New CCC_Logs(Connection)
If I run this simple code, on the database I only find "Log 1!" and "Log 2!" but it seems that "Log 3!" is not persisted, even if no error or exception are raised during the execution of the statement logger.WriteLog(“Log 3!”).
Please, how can I fix this? Why in the catch section the code stops working?
Thank you in advance to anyone who can help