我已经创建了一个存储过程,并从Visual Studio中调用它,但是当我调用存储过程时,该程序出现了编译器错误。该存储过程确实存在于SQL Server中。
这是错误的:
no overload "sumtotal" for method takes 0 argument
SQL Server中的存储过程:
CREATE PROCEDURE sumtotal(@totaling int output)
AS
BEGIN
declare @sum int
set @sum=(select SUM(amount_income) from IncomeTable)
insert into Total_Table(Total_Income)
values(@sum)
set @totaling=@sum
return @totaling
END
GO
在VS中:
AccountDBClassDataContext context = new AccountDBClassDataContext();
int total;
private void button3_Click(object sender, EventArgs e)
{
dataIncome = context.sumtotal();
}
我知道也许我的问题是愚蠢的问题,但这是一个问题。
请帮我 。
干杯。
最佳答案
在存储过程中指定了一个output
参数,因此在调用它时必须传递它:
private void button3_Click(object sender, EventArgs e)
{
int? dataIncome = null;
context.sumtotal(ref dataIncome);
}
关于c# - 调用SQL Server存储过程的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15991897/