在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
原文发布时间为:2008-10-25 —— 来源于本人的百度文章 [由搬家工具导入] 1.获取Return返回值程序代码//存储过程 //Create PROCEDURE MYSQL // @a int, // @b int //AS // return @a + @b //GO SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["LocalSqlServer"].ToString()); conn.Open(); SqlCommand MyCommand = new SqlCommand("MYSQL", conn); MyCommand.CommandType = CommandType.StoredProcedure; MyCommand.Parameters.Add(new SqlParameter("@a", SqlDbType.Int)); MyCommand.Parameters["@a"].Value = 10; MyCommand.Parameters.Add(new SqlParameter("@b", SqlDbType.Int)); MyCommand.Parameters["@b"].Value = 20; MyCommand.Parameters.Add(new SqlParameter("@return", SqlDbType.Int)); MyCommand.Parameters["@return"].Direction = ParameterDirection.ReturnValue; MyCommand.ExecuteNonQuery(); Response.Write(MyCommand.Parameters["@return"].Value.ToString()); 2.获取Output输出参数值 程序代码//存储过程 //Create PROCEDURE MYSQL // @a int, // @b int, // @c int output //AS // Set @c = @a + @b //GO SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["LocalSqlServer"].ToString()); conn.Open(); SqlCommand MyCommand = new SqlCommand("MYSQL", conn); MyCommand.CommandType = CommandType.StoredProcedure; MyCommand.Parameters.Add(new SqlParameter("@a", SqlDbType.Int)); MyCommand.Parameters["@a"].Value = 20; MyCommand.Parameters.Add(new SqlParameter("@b", SqlDbType.Int)); MyCommand.Parameters["@b"].Value = 20; MyCommand.Parameters.Add(new SqlParameter("@c", SqlDbType.Int)); MyCommand.Parameters["@c"].Direction = ParameterDirection.Output; MyCommand.ExecuteNonQuery(); Response.Write(MyCommand.Parameters["@c"].Value.ToString()); |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论