1. 程式人生 > >ADO.NET調用存儲過程

ADO.NET調用存儲過程

輸出 images pro tput ont font reat put color

1)調用無參存儲過程

創建存儲過程:

create procedure usp

as

select *from Student

調用無參存儲過程:

技術分享

2)調用有參存儲過程

創建存儲過程:

alter procedure usp

@gender char(1)

as

select *from Student

where [email protected]


調用有參存儲過程:

技術分享

3)調用輸入和輸出參數存儲過程

創建存儲過程

alter procedure usp

@gender char(1),

@num int output

as

select *from Student

where [email protected]

select @num= count(1) fomr Student

where [email protected]

return 10

查看存儲過程

declare @gender char

set @gender=‘0’

declare @num int

set @num=0

declare @return int

set @return =0

exec @return=usp @gender,@num ouput

print @return

調用輸入與輸出參數存儲過程:

技術分享

ADO.NET調用存儲過程