我想在数据库中插入一条记录,然后需要返回一行。我创建了查询,但如何在 .cs 中使用它(C# 代码)
这是我的查询
@ledgerId numeric(18,0) ,
@voucherNo varchar(MAX) ,
@invoiceNo varchar(MAX) ,
@date datetime ,
@month datetime ,
@totalAmount decimal(18,5) ,
@narration varchar(MAX) ,
-- @extraDate datetime ,
@extra1 varchar(MAX) ,
@extra2 varchar(MAX) ,
@suffixPrefixId numeric(18,0) ,
@voucherTypeId numeric(18,0)
AS
DECLARE @UpdatedVoucherNo DECIMAL(18,0)
SET @UpdatedVoucherNo = (SELECT ISNULL( MAX(CAST (voucherNo AS NUMERIC(18,0))),0) + 1
FROM tbl_SalaryVoucherMaster
WHERE voucherTypeId=@voucherTypeId)
IF (@UpdatedVoucherNo = @voucherNo )
INSERT INTO tbl_SalaryVoucherMaster
(
/*salaryVoucherMasterId,*/
ledgerId,
voucherNo,
invoiceNo,
date,
month,
totalAmount,
narration,
extraDate,
extra1,
extra2,
suffixPrefixId,
voucherTypeId )
VALUES
(
/*@salaryVoucherMasterId, */
@ledgerId,
@voucherNo,
@invoiceNo,
@date,
@month,
@totalAmount,
@narration,
getDate(),
@extra1,
@extra2,
@suffixPrefixId,
@voucherTypeId)
SELECT SCOPE_IDENTITY() AS [Identity],0 AS [UpdatedVoucherNo]