sqlDataReader:

   public SqlDataReader GetAuth_CourtListByAuth(int autIntNo)
{
// Create Instance of Connection and Command Object
SqlConnection myConnection = new SqlConnection(mConstr);
SqlCommand myCommand = new SqlCommand("Auth_CourtListByAuth", myConnection); // Mark the Command as a SPROC
myCommand.CommandType = CommandType.StoredProcedure; SqlParameter parameterAutIntNo = new SqlParameter("@AutIntNo", SqlDbType.Int, );
parameterAutIntNo.Value = autIntNo;
myCommand.Parameters.Add(parameterAutIntNo); // Execute the command
myConnection.Open();
SqlDataReader result = myCommand.ExecuteReader(CommandBehavior.CloseConnection); // Return the data reader
return result;
}

List<Court> courts = new List<Court>();
CourtDB db = new CourtDB(connectionString);
SqlDataReader reader = db.GetAuth_CourtListByAuth(model.SearchAuthority);
while (reader.Read())
{
Court court = new Court();
court.CrtIntNo = Convert.ToInt32(reader["CrtIntNo"].ToString());
court.CrtName = reader["CrtDetails"].ToString();
courts.Add(court);
}
reader.Close();
courts.Insert(0, new Court() { CrtIntNo = 0, CrtName = this.Resource("msgSelectCourt") });
model.CourtList = new SelectList(courts as IEnumerable, "CrtIntNo", "CrtName");

 
 public int GetCourtIntNoByCourtNo(string courtNo)
{
// Create Instance of Connection and Command Object
SqlConnection myConnection = new SqlConnection(mConstr);
SqlCommand myCommand = new SqlCommand("CourtIntNoByCourtNo", myConnection); // Mark the Command as a SPROC
myCommand.CommandType = CommandType.StoredProcedure; // Add Parameters to SPROC
SqlParameter parameterCourtNo = new SqlParameter("@CrtNo", SqlDbType.VarChar, );
parameterCourtNo.Value = courtNo;
myCommand.Parameters.Add(parameterCourtNo); SqlParameter parameterCrtIntNo = new SqlParameter("@CrtIntNo", SqlDbType.Int, );
parameterCrtIntNo.Direction = ParameterDirection.Output;
myCommand.Parameters.Add(parameterCrtIntNo); try
{
myConnection.Open();
myCommand.ExecuteNonQuery();
myConnection.Dispose(); // Calculate the CustomerID using Output Param from SPROC
int getCrtIntNo = Convert.ToInt32(parameterCrtIntNo.Value); return getCrtIntNo;
}
catch (Exception e)
{
myConnection.Dispose();
string msg = e.Message;
return ;
}
}
  public DataSet GetSummonsForJudgement(int crIntNo, DateTime dt, string caseNo,
int pageSize, int pageIndex, out int totalCount, bool isPaidAtCourt = false)
{
SqlConnection con = new SqlConnection(this.connectionString);
SqlCommand com = new SqlCommand("CourtRoomSummonsListForJudgement", con);
com.CommandType = CommandType.StoredProcedure; com.Parameters.Add("@CRIntNo", SqlDbType.Int, ).Value = crIntNo;
com.Parameters.Add("@Date", SqlDbType.DateTime, ).Value = dt;
com.Parameters.Add("@CaseNo", SqlDbType.NVarChar, ).Value = caseNo;
com.Parameters.Add("@PageSize", SqlDbType.Int).Value = pageSize;
com.Parameters.Add("@PageIndex", SqlDbType.Int).Value = pageIndex;
com.Parameters.Add("@IsPaidAtCourt", SqlDbType.Bit).Value = isPaidAtCourt; SqlParameter paraTotalCount = new SqlParameter("@TotalCount", SqlDbType.Int);
paraTotalCount.Direction = ParameterDirection.Output;
com.Parameters.Add(paraTotalCount); DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(com);
da.Fill(ds);
da.Dispose(); totalCount = (int)(paraTotalCount.Value == DBNull.Value ? : paraTotalCount.Value); return ds;
}

sqlserver 取数据常用的更多相关文章

  1. 定时从远程的数据库中取数据,然后把取出来的数据插入或更新本地的oracle数据库的表

    最近项目中有一种需求: 大致需求是这样的 通过给定的 用户名和密码 要定时从远程的数据库中取数据,然后把取出来的数据插入或更新本地的oracle数据库的表 项目的结构式struts1 hibernat ...

  2. MySql与SqlServer的一些常用用法的差别

    MySql与SqlServer的一些常用用法的差别 本文为转载 本文将主要列出MySql与SqlServer不同的地方,且以常用的存储过程的相关内容为主. 1. 标识符限定符 SqlServer [] ...

  3. php中封装的curl函数(抓取数据)

    介绍一个封闭好的函数,封闭了curl函数的常用步骤,方便抓取数据. 代码如下: <?php /** * 封闭好的 curl函数 * 用途:抓取数据 * edit by www.jbxue.com ...

  4. SQLServer导出数据到MySQL

    1从SQLServer导出数据 执行BCP: bcp "..." queryout "F:\test.txt" -c –S1.2.3.4 -Usa -P1111 ...

  5. 借助Chrome和插件爬取数据

    工具 Chrome浏览器 TamperMonkey ReRes Chrome浏览器 chrome浏览器是目前最受欢迎的浏览器,没有之一,它兼容大部分的w3c标准和ecma标准,对于前端工程师在开发过程 ...

  6. C#使用Selenium+PhantomJS抓取数据

    本文主要介绍了C#使用Selenium+PhantomJS抓取数据的方法步骤,具有很好的参考价值,下面跟着小编一起来看下吧 手头项目需要抓取一个用js渲染出来的网站中的数据.使用常用的httpclie ...

  7. 爬虫学习笔记(1)-- 利用Python从网页抓取数据

    最近想从一个网站上下载资源,懒得一个个的点击下载了,想写一个爬虫把程序全部下载下来,在这里做一个简单的记录 Python的基础语法在这里就不多做叙述了,黑马程序员上有一个基础的视频教学,可以跟着学习一 ...

  8. c#基础之异常处理及自定义异常 从SQLServer转储数据到MySQL

    c#基础之异常处理及自定义异常 一.什么是c#中的异常? 异常是程序运行中发生的错误,异常处理是程序的一部分.c#中的异常类主要是直接或者间接的派生于 System.Exception类 ,也就是说S ...

  9. tcpdump 基于mac地址抓取数据包

    1.刚刚接触tcpdump时,常用tcpdump -i eth1 host 192.168.1.1 这个命令基于ip地址抓取数据包信息. tcpdump -i eth1(接口名称) host 192. ...

随机推荐

  1. 使用ssh 初始化git一个空java工程

    1:进入git 目录 cd /home/git/repo/ 2:创建一个java工程名 mkdir qft-payment 3:进入工程 cd  qft-payment/ 4:初始化空工程 git - ...

  2. 聊聊面试中常问的GC机制

    GC 中文直译垃圾回收,是一种回收内存空间避免内存泄漏的机制.当 JVM 内存紧张,通过执行 GC 有效回收内存,转而分配给新对象从而实现内存的再利用. JVM GC 机制虽然无需开发主动参与,减轻不 ...

  3. 16 Z变换

    Z变换 由于\(DTFT\)变换是有收敛条件的,并且其收敛条件比较严格,很多信号不能够满足条件,为了有效的分析信号,需要放宽收敛的条件,引入\(Z\)变换. 定义 已知序列的\(DTFT\)为 \[ ...

  4. retrying 模块

    我们在写爬虫的过程中,经常遇到爬取失败的情况,这个时候我们一般会通过 try 块去进行重试,但是每次都写那么一堆 try 块,真的是太麻烦了,所以今天就来说一个比较 pythonic 的模块,retr ...

  5. Babel的安装和使用

    安装Node.JS 和 npm,如未安装可参照其他文章 1.创建一个package.json npm init (回车, 一直下一步即可) 安装 Babel npm install --save-de ...

  6. eclipse 热部署

    参考: http://blog.sina.com.cn/s/blog_be8b002e0101koql.html

  7. 「Luogu P1975 [国家集训队]排队」

    题目大意 给出一个序列 \(h\),支持交换其中的两数,求出每一时刻的逆序对个数. 分析 求逆序对是 \(O(N\log_2N)\) 的,有 \(M\) 个操作,如果暴力求的话时间复杂度就是 \(O( ...

  8. CSS三列自适应布局(两边宽度固定,中间自适应)

    https://blog.csdn.net/cinderella_hou/article/details/52156333 https://blog.csdn.net/wangchengiii/art ...

  9. python第一章 python基础编程

    第一次学习python 首先python对于我来说是我学习的第三门语言,之前大一学习过了c和c++这两门语言. 接触一个新语言,首先应该的是搭载一下编译的环境.我们是老师给我们上传了的python3安 ...

  10. spring aop @after和@before之类的注解,怎么指定多个切点

    有如下两个切点: @Pointcut("execution(public * com.wyh.data.controller.DepartmentController.*(..))" ...