-2
I have an application that presents me in a textbox the value of a course enrollment:
string mensalidade = string.Format("{0:C}", Convert.ToDouble(leitura["Mensalidade"]));
cursoSelecionado.Mensalidade = mensalidade;
tb_Mensalidade.Text = Convert.ToString(cursoSelecionado.Mensalidade);
As we can see, the field shows the value of this course formatted for the currency style. However, I need to pass only the value of this course, as decimal, to my database (SQL Server).
inserirMatricula.Parameters.Add("@Mensalidade", SqlDbType.Decimal).Value = ???;
How can I do that?
how is the value in
leitura["Mensalidade"]
?– Rodrigo K.B
Of a course, as an example, is 1158.47. It is the value returned in the SQL table.
– Lucas Bustos
You could not pass this variable to your database? this formatting you presented 1158.47, sql server will perfectly accept.
– Rodrigo K.B
No problem at all. The problem is that the field is formatted as a currency for a better user view (indicating a monetary field). Also, when the course value is an integer, for example, "875.00", SQL returns me without the decimals.
– Lucas Bustos