title: Inserting data row into a sql table from another sql table in C#
body: <p>Context: I'm developing an app for windows in Visual Studio that has a table of stock materials and another of buyed materials, both in a Sql Server.
  I want that every time you buy something it is added into the stock table.</p>
  <p>I'm new in using SQL with c# combined.</p>
  <p>I'm trying this from a tutorial, but does nothing. Not even an exception.</p>
  <pre><code>            string cmdString = &quot;Insert INTO Table1 (Column_name) VALUES (@val1)&quot;;
              string connString = @&quot;Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True&quot;;
              using (SqlConnection conn = new SqlConnection(connString))
              {
                  using (SqlCommand comm = conn.CreateCommand())
                  {
  
                      comm.Connection = conn;
                      comm.CommandText = cmdString;                    
                      comm.Parameters.AddWithValue(&quot;@val1&quot;, Value);
                      try
                      {
                          conn.Open();
                          comm.ExecuteNonQuery();
                          conn.Close()
                      }
                      catch(SqlException ex)
                      {
                          
                      }
                  }
              }
  </code></pre>
  <p>Is this totally wrong or should i change something?</p>
  <p><strong>Edit:</strong> I figured out. I was inserting val1 in a column, but the ID was empty so it throws an NullId exception. For some reason in debug mode I wasn't able to see it.</p>
  <p>Thanks for the help. If I have the Table1 with autoincrement why it needs an ID? There is a way that when something is inserted the Id generates automatically?</p>