title: How to pull data from sql, add columns to a row and insert it into another sql table?
body: <p>Hello StackOverflow Community,</p>
  
  <p>I'm trying to programm some kind of Audit Trail function, which should be able to pull data from sql (only one row), add three columns to this row, and insert it into another db table (the audit trail table).</p>
  
  <p>It looks something like this:</p>
  
  <p><img src="https://i.stack.imgur.com/vSIf6.png" alt="enter image description here"></p>
  
  <p>Logic:<br>
  1. SELECT * FROM 'Lace' WHERE 'macaddress' = @mac<br>
  2. Prepend the user, action and timestamp (to know when, which user did what)<br>
  3. Add the modified row into LaceAudit table.</p>
  
  <p>The program looks like this:  </p>
  
  <pre><code>using System;
  using System.Collections;
  using System.Collections.Generic;
  using System.Configuration;
  using System.Data;
  using System.Data.SqlClient;
  using System.Linq;
  using System.Web;
  
  public class Audit2
  {
      private static string _connectionString = ConfigurationManager.ConnectionStrings["LaceDbConnectionString"].ConnectionString;
  
      public enum Action
      {
          Login = 0,
          NewImageInstall = 1,
          OldImageRollback = 2,
          LocalScriptUpdate = 3,
          LaceOffline = 4,
          LaceOnline = 5,
          NewLace = 6,
          NewDepartment = 7,
          NewModel = 8,
          AlterModel = 9,
          NewHardwareId = 10,
          AlterHardwareId = 11
      };
  
      public static void AddToLaceAudit(string user, Action action, string mac)
      {
          // Pull Data with MAC
          DataTable dataTable = GetDataOfLace(mac);
  
          // Add needed columns for the new table
          dataTable.Columns.Add("user", typeof(string));
          dataTable.Columns.Add("action", typeof(int));
  
          // Fill in values for the new columns
  
  
          // Insert DataTable with new values to database
  
  
      }
  
      private static DataTable GetDataOfLace(string mac)
      {
          using (SqlConnection connection = new SqlConnection(_connectionString))
          {
              DataTable _dataTable = new DataTable();
  
              string _query = "SELECT * FROM [Lace] WHERE [macaddress] = @mac";
              SqlCommand command = new SqlCommand(_query, connection);
              command.Parameters.AddWithValue("@mac", mac);
              connection.Open();
  
              SqlDataAdapter da = new SqlDataAdapter(command);
              da.Fill(_dataTable);
              connection.Close();
              da.Dispose();
  
              return _dataTable;
          }
      }
  }
  </code></pre>
  
  <p>How can i now add values to those columns and populate the DataTable with the new values to the database? <code>LaceAudit</code> table already exists. I just need to add the modified row.</p>