DB connection in a container control

Hi @all!
I want to open a connection from a container control in a webapp to a mysql database.
Therefore ein initialized a property called db. In my method i use the following code.

'Dim db As New MySQLCommunityServer db = New MySQLCommunityServer db.Host = "myserver.de" db.SSLMode = true db.Port = 3306 db.DatabaseName = "mydatabase" db.UserName = "myuser" db.Password = "mypassword" If db.Connect Then ' MsgBox "Bin verbunden" else MsgBox(db.ErrorMessage) quit end if

When i use my method and my property in a webpage everything works fine.
When i copy the method and the property to a container control and call the method in the shown event of the container control, the same code is not working.

Who has an idea to get it work? Are there any restrictions i have to know?

Thanks Branko

What do you mean by “not working”? Do you get an error message? What does it say?

Check if the Event fires (eG. put some debug-print in it), there are some bugs, where events doesn’t fire if Container are stacked.
If it works, we need some error output…
In your example you should get the MSGBox with it.

Hi Jay.
Good question :o)
I can run the webapp for debugging. There is no exception or error message.
It seems, that the method was not called. I put an msgbox inside but nothing happens.

So in that case try using Open or use one of the child-controls’ Shown-Event

I tried different things:

  1. Calling the method in the open event of the containercontrol ==> not working, app starts but no functionality
  2. Calling the method in the shown event of the containercontrol ==> not working, app starts but no functionality
    3, Calling the method in shown event of my webpage “containercontrol1.openDB” ==> webapp starts, but quits immidiately with the standard message “The application has gone off-line. Please try again later.”

I am using 2018R4!

What do you see in the debugger?
Try to go through your code line by line and you will see, where you get the problem.

May be something in the project is broken.
I opened a new second project with the same code of my method and it is working as intended!

Strange thing!
Thanks for your suggestions.

Do not use MsgBox for Debugging; add Breakpoints to follow the code execution in the Debugger or System.DebugLog – > Console (if run on macOS)