Как должен выглядеть оператор UPDATE с несколькими столбцами, , которые необходимо обновить? (Потому что ряд сильно изменил его)C# Как обновить таблицу доступа
Я пробовал поиск на этой доске, но в других вопросах иногда «[]» вокруг столбцов, иногда нет, но обе версии не являются работать в моем коде.
Here's код:
try
{
string name = mtb_Name.Text.ToString();
string altname = mtb_AltName.Text.ToString();
string licht = cb_Licht.SelectedItem.ToString();
string boden = cb_Boden.SelectedItem.ToString();
string haerte = cb_Haerte.SelectedItem.ToString();
string pg = cb_PG.SelectedItem.ToString();
string hoehe = mtb_Hoehe.Text.ToString();
string form = cb_Form.SelectedItem.ToString();
string zuechter = cb_Zuechter.SelectedItem.ToString();
string land = cb_Land.SelectedItem.ToString();
string gruppe = cb_Gruppe.SelectedItem.ToString();
//the connection works, I can add stuff in other tables and delete stuff everywhere
parent.GetDBConnection().Open();
OleDbCommand Query = new OleDbCommand();
Query.Connection = parent.GetDBConnection();
Query.Parameters.Clear();
//I build this string at the moment for testing purposes only and
//converted everything and putted in a string to be sure.
//later it will be replaced with the Parameters.Add(,)
//I also did test it with [AltNameRose] as columname instead of AltNameRose
//or wrote instead of the ' ' a "\"" around the strings,
//but doesn´t seem to be the problem.
Query.CommandText = "UPDATE tb_Rose SET" +
" ,AltNameRose = '" + altname +
"' ,NameZuechter = '" + haerte +
"' ,Boden = '" + boden +
"' ,Wuchshoehe = '" + hoehe +
"' ,Farbe = '" + " " +
"' ,Foto = '" + " " +
"' ,Licht = '" + licht +
"' ,Preisgruppe = '" + pg +
"' ,Gruppe = '" + gruppe +
" WHERE NameRose = '" + name + "'";
//the CommandText seems to be missing something, but I don´t know what.
MessageBox.Show(Query.CommandText.ToString());
Query.ExecuteNonQuery();
parent.GetDBConnection().Close();
MessageBox.Show("Rose successfully edited.");
this.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
parent.GetDBConnection().Close();
}
Заброшенная исключение
«SyntaxError в UPDATE-Command
В таблице tb_Rose выглядит следующим образом: NameRose | AltNameRose | NameZuechter | Frosthaerte | Boden | Wuchshoehe | Farbe | Foto | Licht | Preisgruppe | Gruppe
В другом вопросе стоял, что порядок, , как я проходил колонны, тоже важен, , но он не работает для меня.
У кого-нибудь есть небольшой намек, где ошибка?
после множества есть, ' – Sachu