我遇到了 SQLAdapter.Update() 的问题,它不起作用。
table = new DataTable();
mycommand = "select * from klient";
command = new SqlCommand();
command.CommandText = mycommand;
command.Connection = connection;
adapter = new SqlDataAdapter(command);
adapter.Fill(table);
data.ItemsSource = table.DefaultView;
(数据是DataGrid的名称)
当我尝试更新时,它会在数据库中产生影响,但不会在数据网格中产生影响
mycommand= "update klient set imie = 'ze'";
command.CommandText = mycommand;
adapter = new SqlDataAdapter();
SqlCommandBuilder builder = new SqlCommandBuilder(adapter);
adapter.UpdateCommand = command;
adapter.UpdateCommand.ExecuteNonQuery();
adapter.Update(table);
最后一行不起作用。谁能帮我解决这个问题?