Не могу понять почему не записываются данные в БД из переменных
Если пишу в код сами значения, то в БД данные пишутся
Если пишу в код сами значения, то в БД данные пишутся
Сам код"UPDATE wp_zp_orders SET ship_to_name ='Значение' WHERE number = 'Значение'";
Код:
var result = String.Empty;
var command = new MySql.Data.MySqlClient.MySqlCommand();
var connectionSTring = "server=серве;user=юзер;database=названиеБД;password=пароль;";
try {
command.Connection = new MySql.Data.MySqlClient.MySqlConnection(connectionSTring);
}
catch (Exception e) {
result = "MySQL ошибка подключения";
}
if (result!=String.Empty){
return result;
}
try {
command.Connection.Open();
string request = "UPDATE wp_zp_orders SET ship_to_name ='@ship_to_name' WHERE number = '@number'";
MySql.Data.MySqlClient.MySqlCommand com = new MySql.Data.MySqlClient.MySqlCommand (request, command.Connection);
string number = project.Variables ["number"].Value;
string ship_to_name = project.Variables ["ship_to_name"].Value;
com.Parameters.AddWithValue ("@number", number);
com.Parameters.AddWithValue ("@ship_to_name", ship_to_name);
com.ExecuteNonQuery();
}
catch (MySql.Data.MySqlClient.MySqlException e) {
result = "MySql ошибка"+e.Message;
}
finally {
command.Connection.Close();
}
return result;