Connect AdvancedHMI to MySql Database Error?

lunenburger

Member
Join Date
Jul 2008
Location
Summerside
Posts
207
I am trying to open a MySql database within AdvancedHMI.
I have added a button to show a connection, but It is coming back with the error:

Client does not support authentication protocol requested by server; consider upgrading MySQL client

When I run the vb code outside of AdvancedHMI it shows a connection...

I am not sure what the procedure is to get this to work.
any insight would be greatly appreciated...

Here is the vb code that I have in so far:


Imports MySql.Data.MySqlClient

Public Class MainForm
'*******************************************************************************
'* Stop polling when the form is not visible in order to reduce communications
'* Copy this section of code to every new form created
'*******************************************************************************
Private NotFirstShow As Boolean

Private Sub Form_VisibleChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.VisibleChanged
'* Do not start comms on first show in case it was set to disable in design mode
If NotFirstShow Then
AdvancedHMIDrivers.Utilities.StopComsOnHidden(components, Me)
Else
NotFirstShow = True
End If
End Sub

'***************************************************************
'* .NET does not close hidden forms, so do it here
'* to make sure forms are disposed and drivers close
'***************************************************************
Private Sub MainForm_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
Dim index As Integer
While index < My.Application.OpenForms.Count
If My.Application.OpenForms(index) IsNot Me Then
My.Application.OpenForms(index).Close()
End If
index += 1
End While
End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim MySqlConn As MySqlConnection

MySqlConn = New MySqlConnection
MySqlConn.ConnectionString = "server=localhost;userid=root;password=Splash123;database=database"

Try
MySqlConn.Open()
MessageBox.Show("Connected")
MySqlConn.Close()

Catch ex As MySqlException
MessageBox.Show(ex.Message)
Finally
MySqlConn.Dispose()

End Try

End Sub

End Class
 
What version of MySQL? Understand this isn't about AdvancedHMI and MySQL, it's .net and MySQL, which has a ton of support and help. Google is your friend on this.

I think MySQL changed the way it does security in the latest version. That may be the problem here. You could try one of the older versions, I think 5.7. Going off of memory.
 
I am using the latest MySql 8.0.
I can get the button to connect to the database outside of AdvancedHMI, just not when i use the form within AdvancedHMI
 
What's the. Net version of the build you used to test with? Maybe it's something to do with that? Other than making sure you have the correct references, I'm not sure.
 
Are you using Windows authentication or SQL Server Authentication?

With Microsoft SQL Express, the default is to only allow Windows Authentication. There is a setting at the Server/properties level that allows both Windows and SQL authentication. Without that, you cannot use SQL authentication.
 
Last edited:
Open Google search and type this: mysql vb.net tutorial

Watch some of the videos and that should get you started.

I really don't see why using an AHMI project, or a new project would be any different, except for the .NET version you selected on your new project.
 
I am going through some tutorials on youtube, which are very helpful.

It's funny, if i create a new project in a Windows Forms Application, I create a button that shows a connection to the database, it comes back as showing connected. (Same code as I have posted above)

If i create a button and copy that same code into the AdvancedHMI application, it comes back with a key not found exception (see attached pic)


If it's a version issue, should i roll back the MYSql workbench version or Visual Basic?

AdvancedHMI looks awesome!, and I am excited to build my Vb coding skills while using it.

error.jpg
 
It's funny, if i create a new project in a Windows Forms Application, I create a button that shows a connection to the database, it comes back as showing connected. (Same code as I have posted above)

If i create a button and copy that same code into the AdvancedHMI application, it comes back with a key not found exception (see attached pic)


If it's a version issue, should i roll back the MYSql workbench version or Visual Basic?
In the project that is working, try changing it to target .NET Framework 4 to see if that creates the problem.

- In Solution Explorer, right ciick your project and select Properties
- On the Application Tab, change the Target Framework to .NET Framework 4

This is the framework that AdvancedHMI is based on, so that will tell us if the framework version is the issue.
 
You are correct Archie, I rebuilt the working project using version 4 and got the same error.
(if I selected version 4 in the existing project it wouldn't run because it threw out too many errors)

Thanks Archie for a great HMI software package...
 
This isn't a solution, but just to get your feet wet I would roll back on MySQL to 5.7 and see what you get. In my opinion there really isn't anything in 8 that you need right now.
 

Similar Topics

I'm using a SLC typed write from the ControlLogix5572 to the MicroLogix 1400, with path: 2, (MicroLogix IP). The ControlLogix equipment has a...
Replies
0
Views
41
Hello, As part of our project, we are using an M241 controller. This controller interfaces with an industrial computer and a router via a switch...
Replies
2
Views
66
Here's what happened, Operator turned on the disconnect for an auger while it was still running to cut power. Auger DID in fact turn off, but the...
Replies
8
Views
324
What has been your experience with year over year price increases on your Tech-connect service contracts? Is it up to the distributor? 30% seems...
Replies
5
Views
280
Hello, friends, I am trying to upgrade a system that uses an Onrom incremental encoder (E6B2-CWZ6C) connected to a Danfoss VFD (FC360), but now...
Replies
4
Views
270
Back
Top Bottom