如何在VB.NET中实现SQL公式 [英] How to implement SQL Formula in VB.NET
问题描述
嗨
我在vb.net实施了一个
公式
问题是我在做什么跟随
在SQl声明中
当我执行时
此公式
hi
I am implementing a
Formula
in vb.net
The Problem is I am doing as Follows
In SQl Statement
when I am Executing
this Formula
select (CONVERT(INT,(12-11)/2)*0.05+0.75)
i我要退出
.75
但我的问题是,当我在vb.net中实现相同的
as
i am getting out put
.75
but my problem is that when I am implementing the same
in vb.net
as
Dim frm As Decimal = ((12 - 11) / 2) * 0.05 + 0.75
i得不到相同的
am gettin g
0.775
作为输出
但我想要与SQL相同的输出
请帮助我失踪的地方。
i am not getting the Same
am getting
0.775
as output
but i want the same output as SQL
please assist where i am missing.
推荐答案
CONVERT(INT,(12-11)/2)
计算结果为0,导致结果为0.75。 Whearas VB.net语句将其评估为0.5。
如果SQL行为符合预期,那么您可以使用以下代码。
evaluates to 0 which is causing the result to be 0.75. Whearas the VB.net statement evaluates the same to 0.5.
If the SQL behavior is the intended then you can use the following code.
Dim frm As Decimal = (CInt((12 - 11) / 2)) * 0.05 + 0.75
这篇关于如何在VB.NET中实现SQL公式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!