Я пишу приложение для класса, у меня есть рабочие хранимые процедуры для вставки, удаления, изменения, просмотра.
Но этот, этот принимает аргумент, а затем возвращает другое значение , Как мне реализовать это в моем коде?
Это SQL:
USE [ADK_DB]
GO
/****** Object: StoredProcedure [IO].[usp_ukupno_donacija_prema_tipu_krg] Script Date: 3/31/2020 6:52:14 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [IO].[usp_ukupno_donacija_prema_tipu_krg]
@krg_id smallint
as
begin
declare @sum int
select @sum = [IO].[fn_broj_donacija_tip_krg](@krg_id)
print @sum
end;
И вот что я получил за код:
public void DohvatiDonacijePoKG(string krgId)
{
SqlCommand command = new SqlCommand("[IO].[usp_ukupno_donacija_prema_tipu_krg]", cnn);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add(new SqlParameter("@krg_id", SqlDbType.VarChar)).Value = krgId;
//return the output from DB
try
{
command.ExecuteNonQuery();
MessageBox.Show("Success.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show("Execption: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Может Не могу найти подходящее решение для этого поиска в inte rnet, извините, если есть то, что я пропустил.