大佬教程收集整理的这篇文章主要介绍了C# 调用SQL中的存储过程中有output参数,存储过程执行过程中返回信息,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
CREATE PROCEDURE sp_AccountRole_Create @CategoryID int,@Rolename nvarchar(10),@Description nvarchar(50),@RolEID int output AS DECLARE @Count int -- 查找是否有相同名称的记录 SELECT @Count = Count(RolEID) FROM account_Role WHERE Rolename = @Rolename IF @Count = 0 INSERT INTO account_Role (CategoryID,Rolename,Description) valueS (@CategoryID,@Rolename,@Description) SET @RolEID = @@IDENTITY RETURN 1 GO
sqlConnection DbConnection = new sqlConnection(mConnectionString); sqlCommand command = new sqlCommand( "sp_AccountRole_Create",DbConnection ); DbConnection.open(connectString); // 废置sqlCommand的属性为存储过程 command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("@CategoryID",sqlDbType.Int,4); command.Parameters.Add("@Rolename",sqlDbType.NVarChar,10); command.Parameters.Add("@Description",50); command.Parameters.Add("@RolEID",4); // 返回值 command.Parameters.Add("Returnvalue",4,// Size ParameterDirection.Returnvalue,false,// is nullable 0,// byte precision 0,// byte scale String.Empty,Da@R_135_2301@wVersion.Default,null ); command.parameters["@CategoryID"].value = permission.CategoryID; command.parameters["@Rolename"].value = permission.PermissionName; command.parameters["@Description"].value = permission.Description; // 可以返回新的ID值 command.parameters["@RolEID"].Direction = ParameterDirection.output; int rowsAffected = command.ExecuteNonQuery(); int result = command.parameters["Returnvalue"].value; int newID = command.parameters["@RolEID"].value;
command.parameters["Returnvalue"].value 存储过程的返回值
以上是大佬教程为你收集整理的C# 调用SQL中的存储过程中有output参数,存储过程执行过程中返回信息全部内容,希望文章能够帮你解决C# 调用SQL中的存储过程中有output参数,存储过程执行过程中返回信息所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。