I have been trying to connect to a local MySQL database in Visual Studio 2015. This is the code I am using.
Imports System.Data.Sql Imports System.Data.SqlClient
Public Class SQLControl
Public SQLCon As New SqlConnection With {.ConnectionString = "Server=localhost,3306;user=root;database=database;pwd=xxxx;"} Public SQLCmd As SqlCommand Public Function HasConnection() As Boolean Try SQLCon.Open() SQLCon.Close() Return True Catch ex As Exception MsgBox(ex.Message) Return False Finally SQLCon.Dispose() End Try End Function I receive the error: "Internal Connection Fatal Error. Error State: 18"
OR I receive the error: "A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider:TCP Provider, error:0 - An established connection was aborted by the software in your host machine.)
Which error I receive appears to be random. I have changed many settings to no avail, including the port of the server to 1433, which gives me the same errors.
I was wondering if there was any way to solve this through VS 2015 or perhaps the server settings themselves.
Side note: I am able to connect to the database without a problem through VS's server explorer and other programs on this machine (Anypoint Studio), but this does not fulfill the purpose of the project.
using MySql.Data.MySqlClient; using MySql.Data;so you are not using the right classesusing(orImports) then often turn around and just use the sqlserver classes anyway all intermingled and error-prone. See this too stackoverflow.com/a/38277659 .... you could translate that one very easily in your head to vb.net