问题描述
SQL字段;
ID Int NO NULL
价格,Monny
C#
const string query =SELECT Price FROM tabel WHERE ID = @ID
TX_IDText = Convert.ToString(reader [ID]);
TX_Price.Text = Convert.ToString(reader [Price]);
示例1
TX_Price显示1.0000
但这个镜头是1.00
例2
TX_Price显示1.5489
但这个镜头是1.55
如何在查询中更改此内容?
我尝试了什么:
我找到了这个页面,但我不知道如何申请我;
http://sqlusa.com/bestpractices2005/moneyformat/
SQL fields;
ID Int NO NULL
Price, Monny
C#
const string query = "SELECT Price FROM tabel WHERE ID = @ID
TX_IDText = Convert.ToString(reader["ID"]);
TX_Price.Text = Convert.ToString(reader["Price"]);
Example 1
TX_Price shows 1.0000
But this shot be 1.00
Example 2
TX_Price shows 1.5489
But this shot be 1.55
How can I change this in the query?
What I have tried:
I found this page, but I do not know how to apply i;
http://sqlusa.com/bestpractices2005/moneyformat/
推荐答案
SELECT CONVERT(DECIMAL(7,2),MyMoneyColumn) FROM MyTable
double DD;
string SS;
SS = (Double.TryParse(dr["FIELD"].ToString(), out DD) ? DD.ToString("0.00") : "");
listitem.SubItems.Add(SS);
这篇关于在查询中格式化SQL monny字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!