I’m one ear in self learning C# and Unity. Currently I’m in casual development of game. I want to store data in database. I have latest version of Visual Studio and MySQL Server Management Studio.
I succesfuly connected my local DB to VS. I’m able to create tables and add parameters manualy, but I’m not able to comunicate with DB via code itself. The code (below) compile without issue. It seems that I have an error in my connectionString, but I triplececked it.
Can you kick me in the right direction?
using System;
using System.Data;
using MySql.Data.MySqlClient;
public class MySQLConnector
{
public static void Main(string[] arg)
{
string connectionString =
"Server=*servername*;" +
"Database=*DBname*;" +
"Uid=AnyBaddy;"
;
MySqlConnection connection = new MySqlConnection(connectionString);
try
{
connection.Open();
Console.WriteLine("Connection successful!");
}
catch (Exception ex)
{
Console.WriteLine("Error: " + ex.Message);
}
finally
{
connection.Close();
}
}
}
I tryed to create multiple diferent users with different permisions.
I tryed to re/create multiple servers.
I tryed Postgresql instead of SSMS.
2
Answers
Ok, I changed my code to:
After certificate issue i tryed suggestion from comments: How to fix SQL Server 2019 connection error due to certificate issue
Still have the certificate problem.
Add import java.mysql.drivermanager
Add import java.mysql.connection
And download mysql jar from chrome paste it in application
Then you are good to go