Help with MySQL

Hello there , i have a problem with following Code -

Var db As New MySQLCommunityServer
db.Host = “…my - server”
db.Port = 3306
db.DatabaseName = “my database”
db.UserName = “my db username”
db.Password = “my db passwort”

Label1.Text=“Database connected”
Catch error As DatabaseException
// DB Connection error
End Try

Wen i start the Application all works fine… when i change the login information with wrong login credentials, i dont get an message-box with the error-message. The Application will just stop and mark the db.Connect Line…
What could be the Problem ? THX !

You don’t evalute the result of db.Connect - it could be true or false, both are correct results and not an error.

THX for the Quick reply ! I dont Understand… how can i then display a error message if the connection is not working ?

You could try this…

Var mIsConnected as Boolean

mIsConnected = db.Connect

If mIsConnected Then
Label1.Text=“Database connected”
Label1.Text=“Database is not connected”
End If

Catch error As DatabaseException
// DB Connection error
End Try

Use of the Ellipsis character instead of 3 dots ?
Remember: US build application (1) usually does not like non ASCII characters (rule of thumbs).

So try a different string using only ASCII characters (they have a value from 0 to 127, and you better skip those from 0 thru 31 - Control Characters - ).

(1) May I say English speaking countries ?

If this is in the debugger, just press continue. Or turn off BreakOnExceptions.

1 Like

Thank you ! but still it does not open the messagebox with the error.message ???

Thank you !

Yes, because there is no error. If you want to display a messagebox, put it in the if / else clause….

@Thomas_Roemert Connect no longer returns a value; it throws an exception. That’s why the debugger is stopping on that line. He simply needs to click Continue to see the messagebox.