Command.Parameters.Add is Obsolete in MySQL Command
The use of Command.Parameters.Add method in MySql.Data.MySqlClient is deprecated, presenting a warning in Visual Studio. Additionally, it results in inserted values containing the placeholders instead of the intended values.
Corrected Approach
To fix this issue and perform safe queries, follow these steps:
command.Parameters.AddWithValue("@mcUserName", mcUserNameNew); command.Parameters.AddWithValue("@mcUserPass", mcUserPassNew);
"VALUES ('@mcUserName', '@mcUserPass', '@twUserName', '@twUserPass')"
Use:
"VALUES (@mcUserName, @mcUserPass, @twUserName, @twUserPass)"
By following these corrections, you can safely execute queries that are resistant to SQL injection and avoid obsolete methods.
The above is the detailed content of How to Fix the Obsolete `Command.Parameters.Add` Method in MySQL?. For more information, please follow other related articles on the PHP Chinese website!