如何在下面的查询中编写存储过程 [英] How to write stored procedure in the below query
本文介绍了如何在下面的查询中编写存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Sqlstr = "select sum(sal_det_amt) as unpaidleaveamt from salary_details where comp_id = "+strCompanyid+
" and sal_isdeduct = 1 and sal_det_desc LIKE 'Unpaid Leave%' and sal_id IN "+
"(select sal_id from salary_master where comp_id = "+strCompanyid +" and sal_year = " + lngPreviousYear +
" and emp_code = '" + Txt_Employee.Text + "')";
strUnpaidLeaveAmt = cfs.get_data(Sqlstr);
if(strUnpaidLeaveAmt.Trim() !=string.Empty && cfs.IsNumeric(strUnpaidLeaveAmt))
{
dblTempUnpaidLeaveAmt = cfs.IsNumber(strUnpaidLeaveAmt);
}
if( dblTotalSalary > 0 )
{
// TxtAmounts(0).Text = dblTotalSalary - dblTempUnpaidLeaveAmt;
}
strBonus = string.Empty; strBonusDate = string.Empty;
推荐答案
请参阅:在ADO.NET中调用存储过程 [ ^ ]
将您的查询移动到存储过程,您就完成了。
问候..
See this : Calling Stored procedures in ADO.NET[^]
Move your query to the stored procedure and you are done.
Regards..
创建程序Procname
@Companyid int,
@previousyear int,
@empcode varchar(50),
@unpaidleaveamt货币输出
AS
BEGIN
从salary_details选择@ unpaidleaveamt = sum(sal_det_amt)其中comp_id = @CompanyId和sal_isdeduct = 1和sal_det_desc LIKE '未付的离开%'和sal_id IN
(从salary_master中选择sal_id,其中comp_id = @CompanyId和sal_year = @prev iousyear和emp_code = @ empcode)
END
create procedure Procname
@Companyid int,
@previousyear int,
@empcode varchar(50),
@unpaidleaveamt money output
AS
BEGIN
select @unpaidleaveamt=sum(sal_det_amt) from salary_details where comp_id = @CompanyId and sal_isdeduct = 1 and sal_det_desc LIKE 'Unpaid Leave%' and sal_id IN
(select sal_id from salary_master where comp_id = @CompanyId and sal_year = @previousyear and emp_code =@empcode)
END
这篇关于如何在下面的查询中编写存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文