title: Calculate Time from Database
body: <p>I am trying to make my program calculate a break time with data stored in an <code>mysql</code> database.</p>
  
  <pre><code>private void timerpause_Tick(object sender, EventArgs e)
          {
              MySqlConnection conn = DBUtils.GetDBConnection();
              conn.Open();
  
              MySqlCommand dbrequest = conn.CreateCommand();
              dbrequest.CommandText = "SELECT pstart FROM arbeitszeiten WHERE fullname = '" + textBoxfullname.Text + "' and active = 'JA'";
              string pausebeginn = dbrequest.ExecuteScalar().ToString();
  
              MySqlCommand dbrequest2 = conn.CreateCommand();
              dbrequest2.CommandText = "SELECT ptotal FROM arbeitszeiten WHERE fullname = '" + textBoxfullname.Text + "' and active = 'JA'";
              string pausenzeit = dbrequest2.ExecuteScalar().ToString();
  
              TimeSpan pause = Convert.ToDateTime(pausenzeit).TimeOfDay;
              DateTime start = Convert.ToDateTime(pausebeginn);
              TimeSpan zwischen = (DateTime.Now - Convert.ToDateTime(start)).Add(pause);
  
  
              label1.Text = zwischen.ToString();
  
              conn.Close();
          }
  </code></pre>
  
  <p>When the code is executed it tells me: </p>
  
  <pre><code>TimeSpan pause = Convert.ToDateTime(pausenzeit).TimeOfDay;
  </code></pre>
  
  <p>The charters are not detected as a valid <code>DateTime</code> value (Die Zeichenfolge wurde nicht als gültiges DateTime erkannt)</p>
  
  <p>Format:</p>
  
  <pre><code> DB pstart = yyyy-MM-dd HH:mm:ss
   DB ptotal = HH:mm:ss
  </code></pre>
  
  <p>Does anyone see my mistake (besides not having the requests parameterized yet)?</p>