-2
我創建了一個存儲過程,並從Visual Studio調用它,但是當我調用存儲過程時,該程序有一個編譯器錯誤。存儲過程確實存在於SQL Server中。調用SQL Server存儲過程的問題
這是錯誤:
在SQL Serverno overload "sumtotal" for method takes 0 argument
存儲過程:
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 @[email protected]
return @totaling
END
GO
在VS
:
AccountDBClassDataContext context = new AccountDBClassDataContext();
int total;
private void button3_Click(object sender, EventArgs e)
{
dataIncome = context.sumtotal();
}
我知道也許我的問題是愚蠢的問題,但是這是一個題。
請幫幫我。
乾杯。
感謝快速回復。我寫「context.sumtotal(out dataIncome);」但是當我運行時,程序有錯誤。 'Accountant_App.AccountDBClassDataContext.sumtotal(ref int?)'的最佳重載方法匹配有一些無效參數,並且參數1:不能從'out int'轉換爲'ref int?' 。爲什麼?我該怎麼辦? –
謝謝。但爲什麼我應該使用int? ?和int有什麼區別?和int?當我創建一個str prc並且當我調用這個時,我應該使用'ref'變量與'int?'類型?我寫這個,但程序有錯誤:使用未分配的局部變量'dataa' –
'int?'實際上轉換爲'Nullable',並且必須使用它,因爲您的SP無法返回任何值。不同的是,'int?'可以設置爲'null',而標準'int'不能。 –
MarcinJuraszek