When creating a stored procedure with output parameters and returned values --- a low-level error, stored procedure ---
Exception Handling Summary-database http://www.cnblogs.com/dunitian/p/4522990.html Series
Post will be in the blog to start update: http://dnt.dkill.net/Article/Detail/313
Error. How to execute it without the desired effect (return is lost. What else is there ???!!!)
After processing:
If exists (select * from sysobjects where name = 'usp _ AllPmsTest ') drop proc extends proc attributes @ cityName nvarchar (30), @ id int outputasbegininsert into ShopModelBak values (@ cityName, 1, 1) set @ id = @ identityselect CPName, CName, SName, MType, MName, Mprice from ShopMenu inner join ShopModel on ShopMenu. MShopId = ShopModel. SIdinner join View_CityData on ShopMenu. MCityId = CIdwhere CName = @ cityNamereturn (select count (1) from ShopMenu) endgodeclare @ total int, @ id intexec @ total = usp_AllPmsTest 'binhu ', @ id outputselect @ id, @ total
ADO. Net
Var pms = new SqlParameter [] {new SqlParameter ("@ cityName", "binhu district"), new SqlParameter ("@ id", SqlDbType. int), new SqlParameter ("@ total", SqlDbType. int)}; pms [1]. direction = ParameterDirection. output; pms [2]. direction = ParameterDirection. returnValue; var list = SQLHelper. executeReader <ShopMenu> ("usp_AllPmsTest", CommandType. storedProcedure, pms); foreach (var item in list) {Console. writeLine (item. MName + "" + item. MPrice);} Console. writeLine ("the inserted ID is {0}, total {1} pieces of data", pms [1]. value, pms [2]. value );
Related Articles: http://www.cnblogs.com/dunitian/p/5362528.html