i have select query which i made a method off so i can call it anywhere instead of writing query command again and again
public string mysql_execute_selectfromwhere(string select ,string from, string where, string equalsto)
{
ConnMySql.Open();
MySqlCommand com = ConnMySql.CreateCommand();
com.CommandText = "SELECT @1 FROM @2 WHERE @3=@4";
com.Parameters.AddWithValue("@1", select);
com.Parameters.AddWithValue("@2", from);
com.Parameters.AddWithValue("@3", where);
com.Parameters.AddWithValue("@4", equalsto);
string returnstring = Convert.ToString(com.ExecuteScalar());
ConnMySql.Close();
return returnstring;
}
this is how im calling this method
string get = mysql_execute_selectfromwhere("label_name", "label_fields", "lable_id", "17");
im getting following mysql syntax error and i cant seem to understand it properly
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near "label_fields' WHERE 'lable_id'='17" at line 1
please also highlight if there is any other problem with my procedure. Thank you