sean sean - 5 months ago 11
MySQL Question

The Keyword Used is Not Supported (MySQL and Visual Studio 2010)

I am creating a login form using C# and MySQL. I got stuck in SQLConnection. It says that the keyword I used is not supported.

This is my code:

using (var con = new SqlConnection("host=localhost;usr=root;password=admin;db=timekeeping;"))
using (var cmd = con.CreateCommand())
{
con.Open();
cmd.CommandText = "SELECT count(*) FROM receptionist WHERE username = @username AND password = @password;";
cmd.Parameters.AddWithValue("@username", username);
cmd.Parameters.AddWithValue("@password", password);
var count = (long)cmd.ExecuteScalar();
return count > 0;
}


This is the screenshot of the error message:

enter image description here

Answer

You need to use the correct connection string keywords for MySQL:

From Connectionstrings.com:

Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;