存储过程的使用
来源:互联网 发布:网络暴力与道德议论文 编辑:程序博客网 时间:2024/05/17 18:19
存储过程代码如下:
- ALTER PROCEDURE dbo.testOutput
- (
- @p1 int ,
- @p2 int OUTPUT,
- @p3 int
- )
- AS
- /* SET NOCOUNT ON */
- select @p2 = count(*) from testProc where testid between @p1 and @p3
- RETURN @@rowcount
这个存储过程返回2个值,一个是output型参数@p2,另外一个是数据库自带的return值 @@rowcount(语句所影响的行数)。
C#程序:
- SqlCommand com = new SqlCommand("testOutput",con);
- com.CommandType = CommandType.StoredProcedure;
- SqlParameter p1 = new SqlParameter("@p1",SqlDbType.Int);
- SqlParameter p2 = new SqlParameter("@p2",SqlDbType.Int);
- SqlParameter p3 = new SqlParameter("@p3",SqlDbType.Int);
- SqlParameter rowcount = new SqlParameter("@@rowcount", SqlDbType.Int);
- p1.Value = int.Parse(textBox2.Text);
- p2.Direction = ParameterDirection.Output; //把p2设置为output型参数
- p3.Value = int.Parse(textBox3.Text);
- rowcount.Direction = ParameterDirection.ReturnValue;//把rowcount类////型设置为returnvalue型
- com.Parameters.Add(p1);
- com.Parameters.Add(p2);
- com.Parameters.Add(p3);
- com.Parameters.Add(rowcount);
- com.ExecuteNonQuery();
- MessageBox.Show(p2.Value.ToString()); //执行过存储过程以后,output参数p2和@@rowcount就自动返回了值。
- MessageBox.Show(rowcount.Value.ToString());
- 存储过程的使用
- 存储过程的使用
- 存储过程的使用
- 存储过程的使用:
- 存储过程的使用
- 存储过程的使用
- 存储过程的使用
- 存储过程的使用
- 存储过程的使用
- 存储过程的使用
- 存储过程的使用
- 存储过程的使用
- 存储过程的使用
- asp+存储过程的使用
- asp+存储过程的使用
- 使用存储过程的好处
- 使用存储过程的好处
- 使用存储过程的好处
- jQuery做的验证
- 你应该知道的 8 个Java 的领军人物
- asdf
- 求:图书馆管理系统C源代码
- 几种操作系统
- 存储过程的使用
- 求:图书馆管理系统C源代码
- 求:图书馆管理系统C源代码
- 求:图书馆管理系统C源代码
- 求:图书馆管理系统C源代码
- 求:图书馆管理系统C源代码
- 求:图书馆管理系统C源代码
- 测试,不管测试条件如何难以实现,也都要进行测试,没有测试的程序是不合格的程序。
- 简单双运放恒流源电路