can anyone help me, I am trying to connect mysql database, the server details are entered correctly, but when I call the open method, the program throws an exception.
I also used Server explorer, in this case the program sees the server, but I don't know how to use the database connected through Server explorer, that is, how to add it to the project itself.
Please tell me how to fix this error, or how to use the database through Server explorer.
CodePudding user response:
Looking at your code, you are using System.Data.SqlClient
which is a .NET Data Provider for SQL Server.
In your question you state that you try to connect to a mysql database. Use the appropriate nuget package for that
CodePudding user response:
You can’t connect using SqlConnection. you need to install MySqlConnection using nuget package. You can download from https://www.nuget.org/packages/MySqlConnector and you can look how to use section from readme.