title: How to convert string values to float in c#?
body: <p>I have a column in type float in data base. I need to pass a float value taken from a text box to a sql quarry to insert that value to the table in data base.
  However the conversion, </p>
  
  <pre><code>Convert.ToSingle(textbox1.Text)
  </code></pre>
  
  <p>is not working.</p>
  
  <p>I have tried <code>float num = float.Parse(textBox1.Text);</code> also. in both ways a type conversion error is shown.</p>
  
  <p>And in microsoft sql server management 2014 the data type double is not available. </p>
  
  <p>Any help would be highly appreciated.</p>
  
  <p>code:
  private void button5_Click(object sender, EventArgs e)
          {</p>
  
  <pre><code>        if (conn.State.ToString() == "Closed")
          {
              conn.Open();
          }
  
  
          SqlCommand newCmd = conn.CreateCommand();
          newCmd.Connection = conn;
          newCmd.CommandType = CommandType.Text;
          newCmd.CommandText = "insert into salesTable(cusName,cusId,drugName,drugId,strength,quantity,unitPrice,receiptNo) values('" + Convert.ToString(metroTextBox1.Text) + "','" + Convert.ToInt32(metroTextBox2.Text) + "','" + Convert.ToString(metroComboBox1.SelectedItem) + "','" + Convert.ToInt32(metroTextBox4.Text) + "','" + Convert.ToString(metroTextBox5.Text) + "','" + Convert.ToInt32(metroTextBox6.Text) + "','" + Convert.ToSingle(metroTextBox7.Text) + "','" + Convert.ToInt32(metroTextBox8.Text) + "')";
          newCmd.ExecuteNonQuery();
  
  
          conn.Close();
          ClearAllText(this);
          comboFill();
          MessageBox.Show("sale has been recorded.");
      }
  </code></pre>