在C#如何调用存储过程中返回多个值
来源:互联网 发布:淘宝上鹅肝罐头 编辑:程序博客网 时间:2024/05/22 01:43
create proc spFuShouAll
(
@ResultFu int output,
@ResultShou int output,
@Resulta int output,
@ResultFuShou int output,
@ResultFua int output,
@ResultFSC int output
)
AS
Declare @fu int,@shou int,@FristDay datetime,
@LastDay datetime,@result int,@FuShou int,@Fua int, @FSC int
select @FristDay=DATEADD(mm, DATEDIFF(mm,0,getdate()), 0) --取当月的第一天
select @LastDay=DATEADD(ms,-3,DATEADD(mm, DATEDIFF(m,0,getdate())+1, 0))--取当月的最后一天
select @fu=sum(money) from payinvoice
where Datetime between @FristDay and @LastDay
and Cancellation='0'
select @shou=sum(Money) from acceptinvoice --counteractdate字段为抵扣日期
where (counteractdate is null or rtrim(ltrim(counteractdate))='' ) --这句表示counteractdate的值为空
where Datetime between @FristDay and @LastDay --DateTime为收发票日期
and Cancellation='0' --Cancellation字段是否作废 0表示没有作废
select @result=(@fu-@shou)/1.17
select @FuShou=@fu-@shou
select @Fua=@fu*0.01
select @FSC=(@fu-@shou)-(@fu-@shou)/1.17-@fu*0.01
set @ResultFu = @fu --输出收发票总额
set @ResultShou = @shou --输出付发票总额
set @Resulta = @result --输出付发票总额-收发票总额/1.17得到的金额
set @ResultFuShou = @FuShou --输出付发票总额-收发票总额
set @ResultFua = @Fua --输出付发票总额*0.01 应我厂应交的金额
set @ResultFSC = @FSC --输出超出我厂应交的金额数
print @ResultFu
print @ResultShou
print @Resulta
print @ResultFuShou
print @ResultFua
print @ResultFSC
go
在C#要如何调用这个存储过程.
把六个对面的值绑定到
Lab1.Text,Lab2.Text,Lab3.Text,Lab4.Text,Lab5.Text,Lab6.Text
SqlConnection conn;
conn.Open();
comm = new SqlCommand("spFuShouAll",conn);
comm.CommandType = CommandType.StoredProcedure;comm.Parameters.Add(new SqlParameter("@ResultFu",SqlDbType.Int,4,ParameterDirection.Output,false,0,0,null,DataRowVersion.Default,null));
comm.CommandType = CommandType.StoredProcedure;comm.Parameters.Add(new SqlParameter("@ResultShou ",SqlDbType.Int,4,ParameterDirection.Output,false,0,0,null,DataRowVersion.Default,null));
.....其他几个也是这样就不写了
comm.ExecuteNonQuery();
Lab1.Text = comm.Parameters["@ResultFu"].Value.ToString();
Lab2.Text = comm.Parameters["@ResultFu"].Value.ToString();
.....其他几个也是这样
SqlConnection conn;
conn.Open();
comm = new SqlCommand("spFuShouAll",conn);
comm.CommandType = CommandType.StoredProcedure;comm.Parameters.Add(new SqlParameter("@ResultFu",SqlDbType.Int,4,ParameterDirection.Output,false,0,0,null,DataRowVersion.Default,null));
comm.CommandType = CommandType.StoredProcedure;comm.Parameters.Add(new SqlParameter("@ResultShou ",SqlDbType.Int,4,ParameterDirection.Output,false,0,0,null,DataRowVersion.Default,null));
.....其他几个也是这样就不写了
comm.ExecuteNonQuery();
Lab1.Text = comm.Parameters["@ResultFu"].Value.ToString();
Lab2.Text = comm.Parameters["@ResultFu"].Value.ToString();
.....其他几个也是这样
- 在C#如何调用存储过程中返回多个值
- 如何在C#中调用存储过程
- 在C#中如何利用存储过程返回dataset??假设这个存储过程有一个参数
- 怎样在C#中调用存储过程?
- 在C#中调用存储过程
- 在C#中调用存储过程中的两种返回值
- 在ADO中如何调用存储过程
- 如何在存储过程1 调用 存储过程2 ?存储过程2 返回多行记录
- 如何在Delphi中调用oracle的存储过程返回数据集
- 如何在Delphi中调用oracle的存储过程返回数据集
- 如何在Delphi中调用oracle的存储过程返回数据集
- 如何在Delphi中调用oracle的存储过程返回数据集
- 在Qt5.4中调用 sql server 2008 的存储过程如何获取返回值
- C#中调用存储过程并且具有返回值
- 如何在C#中使用存储过程
- c#中如何使用存储过程的返回值
- C#如何调用存储过程
- C#如何调用存储过程
- Symbian OS 开发初级手册 7 Descriptors
- 利用SuppressMessage来阻止FxCop进行代码分析时报出的警告
- 管理信息系统需求调研分析指南
- python(练手-桌面应用) -- 下载器
- socket operation on non-socket
- 在C#如何调用存储过程中返回多个值
- 用资源文件实现Asp.net程序的不同语言间的切换
- C++相关的信息。。。
- MISC
- JPEG转AVI
- WTBS
- Entity的生命周期和状态
- GOOD
- 令人头疼的乱码问题