title: Save edits from dataGridView to SQL Server database (no DataSet or TableAdapter)
body: <p>I have a form with dataGridView to display content of table Attendance</p>
  
  <pre><code>TagID      SessionID       ScanningTime
  ---------------------------------------
  4820427      Test1       14/08/2013 18:12
  </code></pre>
  
  <p>User is able to alter the existing records or add some new ones.</p>
  
  <p>An example of Attendance table after editing the data:</p>
  
  <pre><code>TagID      SessionID       ScanningTime
  ---------------------------------------
  4820000      Test1       14/08/2013 18:12
  0000001      Test2       15/08/2012 17:00
  </code></pre>
  
  <p>I would like the user to be able to save changes from the DGV to SQL server after the button is clicked, but not sure how to achieve this. Please note that I do not use DataSet or TableAdapter when working with DGV.</p>
  
  <p>My code:</p>
  
  <pre><code>private void UpdateBtn_Click(object sender, EventArgs e)
          {
              foreach (var row in dataGridView1.Rows)
              {
  
              string ConnStr = "Data Source=DUZY;Initial Catalog=AutoRegSQL;Integrated Security=True";
  
              SqlConnection MyConn = new SqlConnection(ConnStr);
              MyConn.Open();
  
  
              string query = @"UPDATE Attendance" +
                 " SET TagID= @tagNo, SessionID= @sessionNo, ScanningTime= @scantime ";
  
              SqlCommand command = new SqlCommand(query, MyConn);
  
              command.Parameters.Add("tagNo", SqlDbType.Int).Value = //HOW TO GET VALUE FROM row.TagID column?
              command.Parameters.Add("sessionNo", SqlDbType.Char).Value = //HOW TO GET VALUE FROM row.SessionID column?
              command.Parameters.Add("scantime", SqlDbType.DateTime2).Value = //HOW TO GET VALUE FROM row.ScanningTime column?
  
              SqlDataAdapter adapter = new SqlDataAdapter(command);
  
              adapter.Fill(queryResult);
  
  
  
              RoomActiveSessionForm.DGVSetDataSouce(queryResult);
  
              MyConn.Close();
  
              }
          }
  </code></pre>