如何将方法调用到Command.Parameters.Addwithvalue? [英] How Can I Call A Method Into Command.Parameters.Addwithvalue?
本文介绍了如何将方法调用到Command.Parameters.Addwithvalue?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
private void totalPrice(double two)
{
connection...
command...
command.commandtext = "select @two = sum(TotalPrice) from inventoryout";
command.parameters.addwithvalue("@two", two);
command.exe....
connection.close...
}
//button event
private void btnExe()
{
connection...
command...
command.commandtext = "insert into revenue(...,NewSales,...)values(...,@NewSales,...)";
command.parameters.addwithvalue("@NewSales", totalPrice(two));
command.exe..
close...
}
推荐答案
该方法应该有返回值,以便在AddWithValue调用中使用。例如
The method should have a return value in order to be used in the AddWithValue call. For example
private double totalPrice(double number)
return number * 3;
{
然后
and then
private void btnExe()
{
connection...
command...
command.commandtext = "insert into revenue(...,NewSales,...)values(...,@NewSales,...)";
command.parameters.addwithvalue("@NewSales", totalPrice(2));
command.exe..
close...
}
这篇关于如何将方法调用到Command.Parameters.Addwithvalue?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文