I've been looking for an answer to my question, but i cannot find it, so here it is:
Between String.Format and MySql Parameters, what is the best practice in terms of creating a query for the database.
Here is how i'm using them:
String.Format
string query = String.Format(@"SELECT * FROM users WHERE id = {0}", id);
MySql Parameters
MySqlCommand dbCommand = new MySqlCommand(@"SELECT * FROM users WHERE id = @id");
dbCommand.Parameters.Add("@id", MySql.Data.MySqlClient.MySqlDbType.Int32, 50).Value = id;
If the parameters way is the best practice, i have another question, one of the parameters of the Add function is the size, in the example above is the "50", should i put the same size as i have the database field itself?