Someone please help me I don't know why!
When I insert a value for example 3469,2 into my SQL Server database, I get 34692,0000
The column is of type Money and the value is the type double
// code public void updateligne_facture(String Ref, int Qte,String Reffacture,float prixvente,int tva) { SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=AKRAM-PC\SQLEXPRESS;Initial Catalog=MM_DataBase;Integrated Security=True"; con.Open(); double prix = Qte * prixvente; double prix_ttc = prix * (1 + (tva/ 100D)); String requete = "update lc SET lc.Quantite='" + Qte + "',lc.Prix_HT='"+prix+"',lc.Prix_TTC='"+prix_ttc+"' FROM LIGNES_FACTURE as lc JOIN MM_ARTICLE as art ON lc.ID_Article=art.ID JOIN MM_Facture as f ON lc.ID_Facture=f.ID WHERE art.AR_Ref='" + Ref + "' AND f.Ref='" + Reffacture + "'"; SqlCommand command = new SqlCommand(requete, con); command.ExecuteNonQuery(); con.Close(); }
usingstatement.decimalis the preferred data type overmoneyin SQL Server, because it is far more precise and usable: Should you choose the MONEY or DECIMAL(x,y) datatypes in SQL Server?