sqlserver 取数据常用
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 取数据常用的更多相关文章
- 定时从远程的数据库中取数据,然后把取出来的数据插入或更新本地的oracle数据库的表
最近项目中有一种需求: 大致需求是这样的 通过给定的 用户名和密码 要定时从远程的数据库中取数据,然后把取出来的数据插入或更新本地的oracle数据库的表 项目的结构式struts1 hibernat ...
- MySql与SqlServer的一些常用用法的差别
MySql与SqlServer的一些常用用法的差别 本文为转载 本文将主要列出MySql与SqlServer不同的地方,且以常用的存储过程的相关内容为主. 1. 标识符限定符 SqlServer [] ...
- php中封装的curl函数(抓取数据)
介绍一个封闭好的函数,封闭了curl函数的常用步骤,方便抓取数据. 代码如下: <?php /** * 封闭好的 curl函数 * 用途:抓取数据 * edit by www.jbxue.com ...
- SQLServer导出数据到MySQL
1从SQLServer导出数据 执行BCP: bcp "..." queryout "F:\test.txt" -c –S1.2.3.4 -Usa -P1111 ...
- 借助Chrome和插件爬取数据
工具 Chrome浏览器 TamperMonkey ReRes Chrome浏览器 chrome浏览器是目前最受欢迎的浏览器,没有之一,它兼容大部分的w3c标准和ecma标准,对于前端工程师在开发过程 ...
- C#使用Selenium+PhantomJS抓取数据
本文主要介绍了C#使用Selenium+PhantomJS抓取数据的方法步骤,具有很好的参考价值,下面跟着小编一起来看下吧 手头项目需要抓取一个用js渲染出来的网站中的数据.使用常用的httpclie ...
- 爬虫学习笔记(1)-- 利用Python从网页抓取数据
最近想从一个网站上下载资源,懒得一个个的点击下载了,想写一个爬虫把程序全部下载下来,在这里做一个简单的记录 Python的基础语法在这里就不多做叙述了,黑马程序员上有一个基础的视频教学,可以跟着学习一 ...
- c#基础之异常处理及自定义异常 从SQLServer转储数据到MySQL
c#基础之异常处理及自定义异常 一.什么是c#中的异常? 异常是程序运行中发生的错误,异常处理是程序的一部分.c#中的异常类主要是直接或者间接的派生于 System.Exception类 ,也就是说S ...
- tcpdump 基于mac地址抓取数据包
1.刚刚接触tcpdump时,常用tcpdump -i eth1 host 192.168.1.1 这个命令基于ip地址抓取数据包信息. tcpdump -i eth1(接口名称) host 192. ...
随机推荐
- TensorFlow卷积神经网络实现手写数字识别以及可视化
边学习边笔记 https://www.cnblogs.com/felixwang2/p/9190602.html # https://www.cnblogs.com/felixwang2/p/9190 ...
- ES-Result window is too large
问题: Result window is too large 解决: PUT http://127.0.0.1:9200/catalog/_settings { "index": ...
- JSON parse error: default constructor not found. class java.time.YearMonth; nested exception is com.alibaba.fastjson.JSONException: default constructor not found. class java.time.YearMonth
java8新出的YearMonth可以方便的用来表示某个月.我的项目中使用springmvc来接收YearMonth类型的数据时发现 x-www-from-urlencoded 格式的数据可以使用&q ...
- RTT学习之sensor设备
Sensor设备的常用操作: 首先查找传感器设置获取设备句柄.rt_device_find 以轮询.FIFO.中断.任意一种方式打开传感器,中断和FIFO需要设置接收回调函数(释放一个信号量给接收线程 ...
- Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.1.9.RELEASE from/to 阿里云镜像地址
今天从 http://start.spring.io/ 下载的demo项目,导入eclipse后,pom文件一直报 parent包错,然后感觉就是自己maven镜像里面搜不到这个包, 所以改了 mav ...
- CSS - px、em、%
px(像素).em.% 百分比 1. em 1.1 本元素给定字体的 font-size 值,如果元素的 font-size 为 14px ,那么 1em = 14px:如果 font-size 为 ...
- 简单的单元测试unittest实例
unittest是Python中自带的一个单元测试模块,常常用它来做单元测试,它里面封装了用例的初始化操作和执行,以及返回结果的校验等操作. 在学习unittest框架之前需要先了解几个知识点: Te ...
- zabbix邮件脚本报警
#启动邮箱服务 systemctl start postfix.service #配置用户的邮箱发送邮件 vim /etc/mail.rc set from="xxx@xxx.com&quo ...
- history路由
class HistoryRouter{ constructor(){ //用于存储不同path值对应的回调函数 this.routers = {}; this.listenPopState(); t ...
- Java单例和多例
背景:最近在学习韩老师的笔记时候发现不是很了解单例和多例,于是通过网上查找资料的方式去学习. 设计模式:最佳的实践,是软件开发人员在软件开发过程中面临一般解决方案,也就是开发的经验总结. 单例模式(S ...