• Ado.Net 调用存储过程用法


                SqlDataAdapter da = new SqlDataAdapter("usp_page", conn);          //实例化SqlDataAdapter并且传递存储过程名称和数据库连接
                da.SelectCommand.CommandType = CommandType.StoredProcedure;        //说明传递的SQL语句为存储过程
                SqlParameter[] ps ={                                               //定义数组接收存储过程参数
                                      new SqlParameter("@pageindex",index),        //输入参数指定取值对象
                                      new SqlParameter("@pagecount",count),
                                      new SqlParameter("@total",SqlDbType.Int)      //输出参数指定参数类型
                                  };
                ps[2].Direction = ParameterDirection.Output;              //说明数组中第三个参数为输出参数
                da.SelectCommand.Parameters.AddRange(ps);                 
                DataTable dt = new DataTable();
                da.Fill(dt);
                total = (int)ps[2].Value;                               //接收输出的数值
                this.dataGridView1.DataSource = dt;
  • 相关阅读:
    applicaitonContext属性未注入, 请在applicationContext.xml中定义SpringContextHolder.
    HTML
    c# Path路径类
    C# 继承
    C# 结构体
    c# 类
    c#方法
    wpf开源控件MahApps.Metro
    c#数组类型
    c#类型转换
  • 原文地址:https://www.cnblogs.com/ianism/p/4238163.html
Copyright © 2020-2023  润新知