c# - 调用SQL Server存储过程的问题

标签 c# sql sql-server stored-procedures compiler-errors

我已经创建了一个存储过程,并从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/

相关文章:

mysql - 如何在 foreach 循环后向 powershell 添加 SQL 更新语句

SQL Server 过程声明一个列表

sql - 如何使用存储过程获取所有 SSRS 订阅数据?

C# 从 wmv 文件中抓取帧

c# - 每种类型的自定义 Json.NET 序列化程序设置

mysql - 在 SQL 中创建一个触发器,从一个表中读取数据,并将新数据插入到另一个表中

php - WHERE OR 子句无法正常工作

c# - 负尺寸矩形如何相交?

c# - 如果请求的实体在 Db 中不存在,我应该抛出哪个异常?

sql-server - MSDTC 的问题 - 远程事务