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,
Convert.ToSingle(textbox1.Text)
is not working.
I have tried float num = float.Parse(textBox1.Text); also. in both ways a type conversion error is shown.
And in microsoft sql server management 2014 the data type double is not available.
Any help would be highly appreciated.
code: private void button5_Click(object sender, EventArgs e) {
        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.");
    }