I have a C# program that I want to dynamically create databases with. Although only privileged users will be using this application, I want to follow best practices security wise. How do I go about doing this? I don't think I can use a parameterized query in this case since I'm not wanting to pass in a string, I want to pass in an identifier.
Here's the insecure way I've got in there now as a placeholder:
using (MySqlConnection connection = new MySqlConnection(connectionString))
using (MySqlCommand command = connection.CreateCommand())
{
connection.Open();
command.CommandText = "DROP SCHEMA IF EXISTS " + schema;
command.ExecuteNonQuery();
command.CommandText = "CREATE SCHEMA " + schema;
command.ExecuteNonQuery();
}
Any ideas on this?