Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

How to convert a database float to double

$
0
0

Hello

i hope I'm in the right forum I'm trying to get a float value out the datbase and caculate that column and then show the answer in a textbox. But what is happing is i get an exception i understand that its the wrong format i have tryed everything i can think of.

 SqlConnection con = new SqlConnection("Data Source=warwick-PC; Initial Catalog=Taxi; Integrated Security=True; Trusted_Connection=yes");
            con.Open();
            string sqlCmd;
            sqlCmd = "SELECT * FROM taxi_comm  WHERE Month = '" + cmbStartMonth.SelectedValue+ "'";


            SqlCommand creatCommand = new SqlCommand(sqlCmd, con);
            SqlDataReader dr = creatCommand.ExecuteReader();



            double totalOwed = 0.00;
            foreach (DataGridViewRow row in gvDisplay.Rows)
            {
                double owed = double.Parse(row.Cells[10].ToString());// throws an exception
                totalOwed += owed;
                txtTotalGST.Text = totalOwed.ToString();
            }

            con.Close();

Thanks You for any help


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>