sql - Data Type Money C# -


someone please me don't know why!

when insert value example 3469,2 sql server database, 34692,0000

the column of type money , value 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+"' lignes_facture lc  join  mm_article art on lc.id_article=art.id  join mm_facture f on lc.id_facture=f.id   art.ar_ref='" + ref + "' , f.ref='" + reffacture + "'";         sqlcommand command = new sqlcommand(requete, con);         command.executenonquery();         con.close();     } 

you have problem decimal separator. naming of variables have french(?) system locale. converting variable string inserts comma decimal separator.
sql server wants dot decimal separator if use sql statement. 3469,2 gets 34692.

to work around either
- use parameterized query take care of (strongly recommended) or
- format string conversion of variable use dot decimal separator. have several downsides as: dependent on locales of sql server , prone injection attacks if ever use user entries variable input.


Comments

Popular posts from this blog

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -