程序问题 [英] problem on stroed procedure

查看:88
本文介绍了程序问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,
以下是我的存储过程

Hello friends,
Below is my store procedure

create procedure [dbo].[temptable] (@branchid int,@academicyearid int)
as 
begin
set nocount on
begin try
begin tran
declare @branchname varchar(50)
declare @acfy int ;
declare @acty int
select @branchname=Branch_name from Branch where Branch_id=@branchid
select @acfy=Acadamic_year_from,@acty=Acadamic_year_to from Acadamic_year where Acadamic_year_id=@academicyearid
create table #temptable(Brach_name int,Acadamic_year_from smallint,Acadamic_year_to smallint)
insert into #temptable(Brach_name,Acadamic_year_from,Acadamic_year_to)values(@branchname,@acfy,@acty)
select * from #temptable;
commit
end try
begin catch
rollback
end catch
end
exec temptable 141,11


e
我的任务是我想将branchname和fromyear和year绑定到我的窗口应用程序表单.程序正确吗?执行时,此存储过程没有错误,但是当我以dubug模式跟踪它时,一切正常.但是它没有执行行select * from#temptable.i我想将这三列返回到我的Windows窗体中.请帮助我


e
my task is i want to bind branchname and fromyear and to year to my window application form. is the procedure right or not? When execution there is no error on this store procedure but when i trace this in dubug mode everything ok.but it doesnt execute line select * from # temptable.i want to return thse three column to my windows form. please help me

推荐答案

不要使用事务将值插入到临时表中.

Dont use transaction for inserting values into temp table.

create procedure [dbo].[temptable] (@branchid int,@academicyearid int)
as 
begin
set nocount on

declare @branchname varchar(50)
declare @acfy int ;
declare @acty int
select @branchname=Branch_name from Branch where Branch_id=@branchid
select @acfy=Acadamic_year_from,@acty=Acadamic_year_to from Acadamic_year where Acadamic_year_id=@academicyearid
create table #temptable(Brach_name int,Acadamic_year_from smallint,Acadamic_year_to smallint)
insert into #temptable(Brach_name,Acadamic_year_from,Acadamic_year_to)values(@branchname,@acfy,@acty)
select * from #temptable;

end


exec temptable 141,11


exec temptable 141,11


create procedure temptable (@branchId INT,@academicYearId INT)
as 
begin
set nocount on
declare @branchname VARCHAR(50)
declare @acfy INT;
declare @acty INT
select @branchname=Branch_name from Branch where Branch_id=@branchid
select @acfy=Acadamic_year_from,@acty=Acadamic_year_to from Acadamic_year where Acadamic_year_id=@academicyearid
create table #temptable(Brach_name int,Acadamic_year_from smallint,Acadamic_year_to smallint)
insert into #temptable(Brach_name,Acadamic_year_from,Acadamic_year_to)values(@branchname,@acfy,@acty)
select * from #temptable;
end


这篇关于程序问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆