格式化绑定到数据库列的TextBox [英] Formatting TextBox bound to a database column
问题描述
我面临两个问题,与使用SQL Server格式化VB.NET项目中的文本框有关.
首先,我有一个绑定到"Smallmoney"列的TextBox,它在小数点后最多显示4位数字.我想让它只显示到小数点后2位.
第二,绑定到"Smalldatetime"列的另一个文本框,不允许在"dd-mm-yy"中输入日期.格式.我想以编程方式完成此任务,而无需在区域选项"中进行手动修改.我认为,第二个问题可以使用Culture对象解决,但我不知道该怎么做.
请问有什么可以帮助新手的人!
您可以根据需要返回的值来设计sql.
对于日期,您可以使用CONVERT(CHAR(8),< date file>,103)以dd-mm-yy格式返回
和money转换为0.00格式的convert(varchar,< money field>,0)
I am facing two problems, pertaining to formatting the textboxes in my VB.NET project with SQL Server.
First, I have a TextBox bound to 'Smallmoney' column, which displays the number upto 4 digits after decimal. I want to make it display just to 2 places after decimal.
Second, another TextBox bound to 'Smalldatetime' column, does not let input date in "dd-mm-yy" format. I want to get it done programatically, without manual modifications in the "Regional Options".
I think, the second problem can be solved using the Culture object, but I don't know how to do it.
Is there anybody who can help a novice, please!
you can design your sql according to return the value as you needed.
for date you can user CONVERT(CHAR(8),<date file>,103) to return in dd-mm-yy format
and money as convert(varchar,<money field>,0) as 0.00 format
这篇关于格式化绑定到数据库列的TextBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!