title: WPF datagrid update database
body: <p>I am pretty new in C#. I was writing a small GUI database application which uses a datagrid to show the table data. When I edit a row in the grid press the update button the update function of tableadapter is called and the change is propagated back to DB. Then I have implemented a handler for row changed event which in turns call the update function of tableadapter. But this time when some value is changed and enter key is pressed the handler is called and the InvalidOperationException is raised with the message "There is already an open DataReader associated with this Command which must be closed first." but the database is changed anyways. How to stop the exception to be raised. I have multiple active resultsets set to true in the connection string.  </p>
  
  <p>The constructor</p>
  
  <pre><code>public WSim(MainWindow h)
  {
     InitializeComponent();
  
     //database connection with strongly typed dataset
     usersAdapter = new testDBDataSetTableAdapters.usersTableAdapter();
     users = usersAdapter.GetUsers();
  
     users.usersRowChanged +=new testDBDataSet.usersRowChangeEventHandler(users_usersRowChanged);
  
     this.DataContext = users.DefaultView;
  }
  </code></pre>
  
  <p>The row changed event handler</p>
  
  <pre><code>private void users_usersRowChanged(object sender, testDBDataSet.usersRowChangeEvent e) 
  {
      output.Content = "Row Modified";
      usersAdapter.Update(users);
  }
  </code></pre>
  
  <p>The datagrid xaml</p>
  
  <pre><code>&lt;DataGrid Height="200" HorizontalAlignment="Left" Margin="26,249,0,0" Name="userGrid" VerticalAlignment="Top" Width="381" AutoGenerateColumns="True"
                SelectionMode="Extended" SelectionUnit="FullRow"  ItemsSource="{Binding}"
                CanUserReorderColumns="True" CanUserResizeColumns="True" CanUserSortColumns="True"
                CanUserAddRows="True" CanUserDeleteRows="True"/&gt;
  </code></pre>