如何获取Sum函数结果并将其放入Addwithvalue? [英] How Can I Get The Sum Function Result And Put It In The Addwithvalue?
本文介绍了如何获取Sum函数结果并将其放入Addwithvalue?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
选择SUM(TotalPrice)FROM inventoryout,其中Newsales = @ two
cmd.Parameters.AddWithValue( @ two,SqlDbType.Decimal);
解决方案
AddWithValue将实际值作为第二个参数,而不是值的类型。因此,假设Newsales列是Int32类型,这将是有效的:
int newsales = 1 ;
cmd.Parameters.AddWithValue( @ two,newsales);
Select SUM(TotalPrice) FROM inventoryout where Newsales=@two
cmd.Parameters.AddWithValue("@two", SqlDbType.Decimal);
解决方案
AddWithValue takes the actual value as second parameter, not the Type of the value. So, assuming the column "Newsales" is of Type Int32, this would be valid:
int newsales = 1; cmd.Parameters.AddWithValue("@two", newsales);
这篇关于如何获取Sum函数结果并将其放入Addwithvalue?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文