I tried to use this code to login to my vb.net application using mysql. But I have this error
An unhandled exception of type 'System.Security.Authentication.AuthenticationException' occurred in MySql.Data.dll. Additional information: Échec d'un appel à SSPI, consultez l'exception interne. I have this error only with windows 10, there are no problems with Windows 7
I read here a solution.
I tried to add this line
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;" before
Dim Str As String = "SERVER=localhost;
uid =root;
DATABASE =mag;
PASSWORD =;""
but it didn't work.
Imports MySql.Data.MySqlClient
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim Str As String = "SERVER=localhost; uid =root;DATABASE =mag;PASSWORD =;"
Dim cc As New MySqlConnection(Str)
Try
conn.Open()
Dim Sql = "SELECT * FROM tab1 WHERE login='" & TextBox1.Text & "' and password='" & TextBox2.Text & " '"
Dim cmd = New MySqlCommand(Sql, cc)
Dim dr = cmd.ExecuteReader
dr.Read()
If dr.HasRows = 0 Then
MsgBox("Error.", vbQuestion)
Else
Me.Hide()
Form2.Show()
End If
Catch ex As MySqlException
MessageBox.Show(ex.Message)
End Try
End Sub
End Class