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. ...
随机推荐
- TOMCAT中文信息乱码改为GBK
# Licensed to the Apache Software Foundation (ASF) under one or more# contributor license agreements ...
- 获取 python linux Home目录
#! /usr/bin/python # -*- coding: utf-8 -*- import os print os.environ['HOME'] print os.path.expandva ...
- c#本地缓存当数据库表更改时,缓存失效。
web.config <?xml version="1.0" encoding="utf-8"?> <!-- 有关如何配置 ASP.NET 应 ...
- 安洵杯iamthinking(tp6反序列化链)
安洵杯iamthinking tp6pop链 考点: 1.tp6.0反序列化链 2.parse_url()绕过 利用链: 前半部分利用链(tp6.0) think\Model --> __des ...
- Node.js介绍、优势、用途
一.Node.js介绍Node.js是一个javascript运行环境.它让javascript可以开发后端程序,实现几乎其他后端语言实现的所有功能,可以与PHP.Java.Python..NET.R ...
- 吴裕雄--天生自然TensorFlow2教程:梯度下降简介
import tensorflow as tf w = tf.constant(1.) x = tf.constant(2.) y = x * w with tf.GradientTape() as ...
- 2016-2017学年第三次测试赛 习题H MCC的考验
问题 H: MCC的考验 时间限制: 1 Sec 内存限制: 128 MB 题目描述 MCC男神听说新一期的选拔赛要开始了,给各位小伙伴们带来了一道送分题,如果你做不出来,MCC会很伤心的. 给定一 ...
- Jmeter_Http默认请求值
1.线程组->配置原件->Http请求默认值 2.作用:几个Http 请求参数都是重复的数据 3.优先级:Http请求默认值和单个Http请求数值,使用单个Http请求数值为主 举例如下: ...
- 十、Spring中常用注解-分层整理
1.@Controller: 标注展示层组件(Bean),但是目前该功能与 @Component 相同,用来创建处理http请求的对象 Spring4之后加入的注解,原来在@Controller中 ...
- python2.7 安装 Scipy
Numpy.scikit-learn可以直接 pip install xxx 但Scipy不能,在官网找到了安装方法: python -m pip install --user numpy scipy ...