title: C#: Inserting values into database
body: <p>I´ve WPF application where i have button SaveData which calls function InsertValuesIntoGAStatistics and i want to insert data into database but nothing is inserted i don´t know where is problem everything looks fine and i didn´t get any error message just nothing is done.</p>
  
  <pre><code>private void SaveData_Click(object sender, RoutedEventArgs e)
  {
      database.InsertValuesIntoGAStatistics("haha", 4, 4, 4, 4, 11, "hlalha", "blabla", "blabsdla");
  }
  </code></pre>
  
  <p>button for saving data</p>
  
  <pre><code>public static string ConnectionStringGADatabase
  {
      get
      {
          return ConfigurationManager.ConnectionStrings["GADatabase"].ConnectionString;
      }
  }
  </code></pre>
  
  <p>here is property to get connectionString</p>
  
  <pre><code>public void InsertValuesIntoGAStatistics(string GAType, int Generations, int PopulationSize, float MaxFitness, float AverageFitness, int DmaxValue, string Selection, string CrossOver, string FilePath)
  {
      try
      {
          using (SqlConnection connection = new SqlConnection(Connection.ConnectionStringGADatabase))
          using (SqlCommand command = connection.CreateCommand())
          {
              command.CommandText = "INSERT INTO GAStatistics (GAType, Generations, PopulationSize, MaxFitness, AverageFitness, DmaxValue, Selection, CrossOver, FilePath) VALUES (@GAType, @Generations, @PopulationSize, @MaxFitness, @AverageFitness, @DmaxValue, @Selection, @CrossOver, @FilePath)";
              command.Parameters.AddWithValue("@GAType", GAType);
              command.Parameters.AddWithValue("@Generations", Generations);
              command.Parameters.AddWithValue("@PopulationSize", PopulationSize);
              command.Parameters.AddWithValue("@MaxFitness", MaxFitness);
              .............
              connection.Open();
              command.ExecuteNonQuery();
          }
      }
      catch (SqlException ex)
      {
          Console.WriteLine(ex.Message);
      }
  }
  </code></pre>
  
  <p>this is function InsertValuesIntoGAStatistics which should insert data into database</p>
  
  <pre><code>&lt;connectionStrings&gt;
  &lt;add name="GADatabase" connectionString="Data Source=LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Database\GADatabase.mdf;Integrated Security=True" 
       providerName="System.Data.SqlClient" /&gt;
  &lt;/connectionStrings&gt;
  </code></pre>
  
  <p>and this part of code is in App.config file</p>