存储过程系列之存储过程sql数据库调用和程序代码调用
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数据库调用和程序代码调用的更多相关文章
- 直接拨号、将电话号码传入拨号程序、调用拨号程序、调用系统浏览器浏览网页、调用系统程序查看联系人、显示系统设置界面和显示Wi-Fi设置界面代码
直接拨号.将电话号码传入拨号程序.调用拨号程序.调用系统浏览器浏览网页.调用系统程序查看联系人.显示系统设置界面和显示Wi-Fi设置界面代码 拨打号码的代码如下: Intent callIntent= ...
- 存储过程系列之存储过程具体操作过程及sql数据库调用
Transact-SQL中的存储过程,非常类似于Java语言中的方法,它可以重复调用.当存储过程执行一次后,可以将语句缓存中,这样下次执行的时候直接使用缓存中的语句.这样就可以提高存储过程的性能. 存 ...
- 存储过程学习笔记(SQL数据库
一. 存储过程简介 Sql Server的存储过程是一个被命名的存储在服务器上的Transacation-Sql语句集合,是封装重复性工作的一种方法,它支持用户声明的变量.条件执行和其他强大的编程 ...
- 存储过程系列之存储过程sql查询存储过程的使用
1.查询某个表被哪些存储过程(以下简称 SP)使用到 : select distinct object_name(id) from syscomments where id in (select ob ...
- PHP中实现异步调用多线程程序代码
本文章详细的介绍了关于PHP中实现异步调用多线程方法,下面我们以给1000个用户发送一封推荐邮件,用户输入或者导入邮件账号了提交服务器执行发送来讲述. 比如现在有一个场景,给1000个用户发送一封推荐 ...
- python调用C程序代码
DHT11的驱动使用C语言编写 然后用python调用C的程序 显示温湿度 pycall.py文件如下: #!/usr/bin/env python # -*- coding:utf-8 -*- ...
- jira webhook 事件触发并程序代码调用jenkins接口触发构建操作
要解决的问题 开发管理工具触发站点构建事件,事件处理中需要调用Jenkins接口开始构建动作. 我的应用场景: 使用jira作为管理工具,在jira中创建自定义的工作流来规定测试,上线,发布等流程,并 ...
- [AIR] AIR 应用程序的调用和终止
本节讨论几种对已安装的 Adobe® AIR® 应用程序进行调用的方法,以及关闭运行中的应用程序的选项和注意事项. 注: NativeApplication.InvokeEvent 和 Browser ...
- 全国天气预报信息数据 API 功能简介与代码调用实战视频
此文章对开放数据接口 API 之「全国天气预报信息数据 API」进行了功能介绍.使用场景介绍以及调用方法的说明,供用户在使用数据接口时参考之用,并对实战开发进行了视频演示. 1. 产品功能 接口开放了 ...
随机推荐
- Classloaders and Classes
Classloaders and Classes (CLASSES) An example of the classloader (CLASSES) section that includes Cla ...
- SC命令---安装、开启、配置、关闭 cmd命令行和bat批处理操作windows服务
一.cmd命令行---进行Windows服务操作 1.安装服务 sc create 服务名 binPath= "C:\Users\Administrator\Desktop\win32s ...
- C 语言 查找一个字符串2在字符串1中出现的次数
#include <stdio.h> #include <windows.h> int main() { ], b[]; char *temp; ; memset( a, ); ...
- Codevs 1684 垃圾陷阱
1684 垃圾陷阱 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题目描述 Description 卡门--农夫约翰极其珍视的一条Holsteins奶牛--已经落了 ...
- 以boost::function和boost:bind取代虚函数
转自:http://blog.csdn.net/Solstice/archive/2008/10/13/3066268.aspx 这是一篇比较情绪化的blog,中心思想是“继承就像一条贼船,上去就下不 ...
- 九度OJ 1480 最大上升子序列和 -- 动态规划
题目地址:http://ac.jobdu.com/problem.php?pid=1480 题目描述: 一个数的序列bi,当b1 < b2 < ... < bS的时候,我们称这个序列 ...
- centos 安装qrcode 二维码
先安装yum install mingw64-pkg-config.x86_64 yum install cairo-devel 然后报错,好像是gcc版本有点低,现在的版本是4.4.7 那么接下来 ...
- thinkphp验证码的实现
两种验证码验证实现,一种直接在form表单提交按钮实现验证,一种使用ajax传递参数实现验证: 1.直接在form表单提交按钮实现验证,在控制器VerifyController.class.php中写 ...
- WPF的ScrollViewer鼠标的滚动
在C# 中,两个ScrollViewer嵌套在一起或者ScrollViewer里面嵌套一个ListBox.Listview(控件本身有scrollviewer)的时候,我们本想要的效果是鼠标滚动整个S ...
- MVC-各种传值方式
[转自]:QLeelulu示例一:ViewData传值.HomeController.cs Co de: public ActionResult Index(){ ViewData[" ...