I want to know how to select data from MariaDB in C# with variable value in where condition. Please see my code, I am getting this error:
MySql.Data.MySqlClient.MySqlException: 'You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '@gmail.com' at line 1'
Please correct me with my code if I am wrong.
Here is my code
var2 = Forms.frmLogin.var1;
connection2.Open();
string selectQuery = "Select Role from car_dealer.users where email = "+var2+" ";
command = new MySqlCommand(selectQuery, connection2);
mdr = command.ExecuteReader();
if (mdr.Read())
{
var3 = mdr.GetString("Role");
}
//lblUsername.Text = var2;
connection2.Close();
MessageBox.Show(var3);