Reputation: 13
im very likely missing some obvious setup, im using XAMPP following a beginner project tutorial to make database, however i am getting an error System.ArgumentException: 'Option not supported. at
private MySqlConnection connection = new MySqlConnection("datasource:127.0.0.1;port=3306;username=root;password=;database=Csharp_Hotel_DB");
i already did search how to connect to MySQL but found no different than what said tutorial did :
-add MySql.Data.dll as reference,
-using MySql.Data.MySqlClient;
-making empty table at localhost/phpmyadmin via XAMPP
and then test the connection withif(table.Rows.Count > 0) {MessageBox.Show("Yes");} else {MessageBox.Show("No");}
assigned to a button. the program works but clicking the button give error message above.
Upvotes: 1
Views: 1058
Reputation: 218847
According to the example I found here (and an additional resource I often consult here for different RDBMSs I encounter), the parameters in your connection string are mis-named:
datasource:127.0.0.1;port=3306;username=root;password=;database=Csharp_Hotel_DB
It should be:
Server=127.0.0.1;Port=3306;Uid=root;Pwd=;Database=Csharp_Hotel_DB
It looks like you may be formatting the connection string based on MS SQL Server standards instead. Most C# examples you find online will likely have that since it's the same vendor. But the connection string depends on the RDBMS, not on the language connecting to it. Which in this case is MySQL.
Upvotes: 2