1、存储过程,无参数的存储过程

创建无参数存储存储过程

Create Procedure DCEMREMR_TEMPLATE
As
SELECT TOP 10 [FILENAME],[FILETITLE],[FILECONTENT] from [DCEMR].[dbo].[EMR_TEMPLATE];

调用无参数存储存储过程

sql 数据库中的额调用  exec DCEMREMR_TEMPLATE;

sql程序代码调用

//无参数存储过程
string connecting = "Data Source=localhost;Integrated Security=SSPI;Initial Catalog=DCEMR";
SqlConnection theConnect = new SqlConnection(connecting);
theConnect.Open();
SqlCommand theCommand = theConnect.CreateCommand();
theCommand.CommandText = "DCEMREMR_TEMPLATE";
theCommand.CommandType = CommandType.StoredProcedure;
SqlDataReader theReader = theCommand.ExecuteReader();
while (theReader.Read())
{
string xx = theReader.GetString(0).ToString();
}
theConnect.Close();

2、有参数存储过程,无返回值

创建有参数存储存储过程,无返回值

Go
Create Procedure DCEMREMRTEMPLATE100
@filename nvarchar(500)
As
SELECT [FILENAME],[FILETITLE],[FILECONTENT] from [DCEMR].[dbo].[EMR_TEMPLATE] where [FILEname]=@filename;

调用有参数存储过程,无返回值

sql 数据库中的额调用  exec DCEMREMRTEMPLATE100 ‘新建目录’;

sql程序代码调用

//有参数存储过程,无返回值
string connecting = "Data Source=localhost;Integrated Security=SSPI;Initial Catalog=DCEMR";
SqlConnection theConnect = new SqlConnection(connecting);
theConnect.Open();
SqlCommand theCommand = theConnect.CreateCommand();
theCommand.CommandText = "DCEMREMRTEMPLATE101";
theCommand.CommandType = CommandType.StoredProcedure;
theCommand.Parameters.Add("@filename",SqlDbType.NVarChar);
theCommand.Parameters["@filename"].Value = "新建目录";
SqlDataReader theReader = theCommand.ExecuteReader();
while (theReader.Read())
{
string xx = theReader.GetString(0).ToString();
}
theConnect.Close();

3、有参数存储过程,有返回值(参数@filename,返回参数@Rowcount)

创建有参数存储过程,有返回值

Go
Create Procedure DCEMREMRTEMPLATE101
@filename nvarchar(500),
@Rowcount int output
As
SELECT [FILENAME],[FILETITLE],[FILECONTENT] from [DCEMR].[dbo].[EMR_TEMPLATE] where [FILEname]=@filename
set @Rowcount=@Rowcount;

调用参数存储存储过程,有返回值

sql 数据库中的额调用  exec DCEMREMRTEMPLATE101 ‘新建目录’,2;

sql程序代码调用

//有参数存储过程
string connecting = "Data Source=localhost;Integrated Security=SSPI;Initial Catalog=DCEMR";
SqlConnection theConnect = new SqlConnection(connecting);
theConnect.Open();
SqlCommand theCommand = theConnect.CreateCommand();
theCommand.CommandText = "DCEMREMRTEMPLATE101";
theCommand.CommandType = CommandType.StoredProcedure;
theCommand.Parameters.Add("@filename",SqlDbType.NVarChar);
theCommand.Parameters["@filename"].Value = "新建目录";
theCommand.Parameters.Add("@Rowcount", SqlDbType.Int);
theCommand.Parameters["@Rowcount"].Direction = ParameterDirection.Output;
//theCommand.Parameters["@Rowcount"].Value = 2;

//theCommand.ExecuteNonQuery();
object ss = theCommand.ExecuteScalar();
//MessageBox.Show( theCommand.Parameters["@Rowcount"].Value.ToString());
SqlDataReader theReader = theCommand.ExecuteReader();
while (theReader.Read())
{
string xx = theReader.GetString(0).ToString();
}
theConnect.Close();

存储过程系列之存储过程sql数据库调用和程序代码调用相关推荐

  1. 根据Word表格自动生成SQL数据库脚本的VBScript代码

    这是几年前写的根据Word表格自动生成SQL数据库脚本的VBScript代码,最近修改了下(原来只支持单个Word表格)使其支持一个Word文档中的多个表格,生成的SQL文件名以Word文件名+.SQ ...

  2. mysql 数据字典 php_php生成mysql数据库数据字典的程序代码

    php生成mysql数据库数据字典的程序代码,比较实用,具体代码如下:header('Content-type:text/html;charset=utf-8'); /** * 生成mysql数据字典 ...

  3. 存储过程系列之存储过程具体操作过程及sql数据库调用

    Transact-SQL中的存储过程,非常类似于Java语言中的方法,它可以重复调用.当存储过程执行一次后,可以将语句缓存中,这样下次执行的时候直接使用缓存中的语句.这样就可以提高存储过程的性能. 存 ...

  4. 存储过程学习笔记(SQL数据库

    一.   存储过程简介 Sql Server的存储过程是一个被命名的存储在服务器上的Transacation-Sql语句集合,是封装重复性工作的一种方法,它支持用户声明的变量.条件执行和其他强大的编程 ...

  5. 三菱FX5U、Q系列、L系列PLC与SQL数据库双向通讯,对接MES

    IGT-SER智能网关模块,支持各种PLC.智能仪表.远程IO与数据库之间双向通讯,既可以读取设备的数据上报到SQL数据库,也可以从数据库查询数据后写入到设备:PLC内无需编写通讯程序:支持局域网和外 ...

  6. linux下java调用matlab程序,linux_java调用windows_matlab程序

    0 说明 本文为研究java和matlab的混合编程,进行了详细的测试和探索,以解决linux环境下java程序调用matlab程序的一个应用. linux端的环境 :(运行java程序并调用wind ...

  7. java 调用casperjs_Java程序去调用并执行shell脚本及问题总结(推荐)

    摘要: 该文章来自阿里巴巴技术协会(ATA)精选集 背景 我们在开发过程中,大部分是java开发, 而在文本处理过程中,主要就是脚本进行开发. java开发的特点就是我们可以很早地进行TDDL, ME ...

  8. php用存储过程插入数据,如何使用php-webservice使用android中的存储过程将数据插入sql数据库[duplicate]...

    下面是utf-8版本,有几个异常处理: static InputStream is = null; static JSONObject jObj = null; static String json ...

  9. 存储过程系列之存储过程返回值总结

    sql存储过程返回值总结 1. 存储过程没有返回值的情况(即存储过程语句中没有return之类的语句)用方法 int count = ExecuteNonQuery(..)执行存储过程其返回值只有两种 ...

最新文章

  1. js进阶课程 12-9 jquery的事件对象event的方法有哪些?
  2. “金主爸爸快回来交学费吧!”疫情让中国留学生难以返校,国外高校面临资金短缺...
  3. python可以做什么毕业设计-Python
  4. 转载:指定浏览器打开指定的网页
  5. 项目中要使用到动态规划该怎么应用,怎么说?
  6. python观察日志(part9)--数据库与pickle模块
  7. 用Jquery实现选项卡功能
  8. mysql on后加and_mysql加入ON和AND to laravel eloquent
  9. Package fontspec Error: The font “SimHei“ cannot be found. windows 上海交大学位论文模板
  10. Python网络爬虫:空姐网、糗百、xxx结果图与源码
  11. Source(拉电流) Sink(灌电流)详解
  12. 批量将多个 Excel 工作簿文件合并成单个 Excel 文件
  13. 关于网络营销基本理论的概述
  14. ffmpeg水印制作
  15. 微信公众平台开发:JS API支付
  16. 关于如何修复移动热点无网络(无互联网连接)的问题
  17. 石膏板GCC认证床垫GCC认证亚马逊美国
  18. CVPR2022 目标检测方向文章(附摘要)
  19. css3实现向一个方向无缝连接滚动
  20. vscode的颜色设置(护眼模式)

热门文章

  1. DXperience 6.3.9 for Visual Studio 2002, 2003
  2. PDF文件能编辑吗,怎么删除PDF文档中的空白页
  3. MyBatis集成SpringMVC
  4. UI Framework-1: Ash Color Chooser
  5. BGP多出口多宿主实验
  6. 运维学习之自动化安装系统的配置
  7. 打造云上深度学习实验室
  8. 一文读懂机器学习、数据科学、人工智能、深度学习和统计学之间的区别
  9. centos7 hostnamectl
  10. 使用cronolog自动分割apache的日志。