维护基于ASP.NET的网站的学习-SqlCommand类介绍及存储过程
笔者目前在维护学校科技处的一个网站,目前学期初,教师申报项目操作多,出现了一些问题。前几天维护了一个验证码图片不显示的bug,今天想记录下这个解决了一整天的bug-老师项目结题需要手动修改数据库老师项目的结题状态为1,否则该老师无法继续申报项目。(以解决过程为主线介绍,最后附加SqlCommand类的介绍)
针对这个问题,我首先定位了页面,在源码中分析了一下逻辑,aspx.cs页面代码如下
cmd = new SqlCommand("[sp_review_is_shenbao]", Con);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter paroutput = cmd.Parameters.Add("@i_num", SqlDbType.Int);
paroutput.Direction = ParameterDirection.Output;
cmd.Parameters.AddWithValue("@type", "is_shenbao");
cmd.Parameters.AddWithValue("@work_card", str_card);
cmd.Parameters.AddWithValue("@other", "");
cmd.Parameters.AddWithValue("@other2", "");
row = cmd.ExecuteNonQuery();
Con.Close();
int i_num = int.Parse(paroutput.Value.ToString());
if (i_num == 0)
{
this.lb_exist.Visible = false;
this.lb_exist.Text = "";
this.LinkButton4.Enabled = true;
}
else
{
this.lb_exist.Visible = true;
this.lb_exist.Text = "对不起,您不符合申报条件,不可以进行申报。";
this.LinkButton4.Enabled = false;
}
其中的第一行代码我没有接触过,SqlCommand的第一个参数是一个存储过程,以前接触的都是sql语句,sql语句中有对数据库表格的定位和操作,而存储过程在数据库中封装,首先需要打开sqlserver数据库的可编程性>存储过程>系统存储过程>找到自己需要的存储过程名称>右键修改就可以查看了,如图
cmd = new SqlCommand("[sp_review_is_shenbao]", Con);
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAXkAAAEqCAIAAAB/e7czAAAgAElEQVR4nO2dTYgcSZbn/diHGUpHHRqmAga2Awqmg51DJejQmdAHJdQ0SqiDErS0OtFBJH1QJ4IVSR5KJDoUiaa7SRJWaJOiIDVQM6Eelk2xFJuqhV1Uh2YjDwIr2FwiD1rwg5byQy5rBw3x5hAhl6e9Z8/Mv7/en0fgYW72zNzD7RfPPdxf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+iT6iYAAAAAElFTkSuQmCC" alt="" />
打开存储过程为
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go ALTER PROCEDURE [dbo].[sp_review_is_shenbao] //创建名称为sp_review_is_shenbao的存储过程
@i_num int output, //一些参数创建
@type char(20),
@work_card char(20),
@other varchar(50),
@other2 varchar(200)
AS BEGIN
//具体逻辑处理
if(@type='is_shenbao') //如果年龄大于四十岁不可以申报项目
begin
declare @age int
declare @year datetime
set @year=(select dateadd(ms,-3,dateadd(yy,datediff(yy,0,getdate())+1,0)))
set @age=(select datediff(yyyy,birthday,@year) from table_person where work_card=@work_card )
if(@age>40)
begin
set @i_num=1
end
else
begin
set @i_num=0
end declare @jieti int //如果以前是项目不是结题状态,不可以继续申报项目
set @jieti=(SELECT count(project_id) as num FROM review_project_info where work_card=@work_card and is_jieti=0
and state_manage='1' )
if(@jieti=0)
begin
set @i_num=@i_num+0
end
else
begin
set @i_num=@i_num+1
end end
END
具体的逻辑就是,老师的年龄必须大于四十岁并且以前的所有项目均结题,才可以继续申报项目。需求是,手动改动数据库,将所有教师的所有项目改为结题状态,目的是让他们可以继续申报项目。通过存储过程,确定了是表review_project_info中存储了项目的结题状态,新建查询,输入update review_project_info set is_jieti=1;改动。
测试满足需求,结束。
最后,介绍下SqlCommand类
1.SqlCommand类的构造函数有四种重载形式:
SqlCommand();
SqlCommand(String);
SqlCommand(String,SqlConnection); //主意String可以为存储过程和sql语句,例如,cmd = new SqlCommand("[sp_review_is_shenbao]", Con);
SqlCommand(String,SqlConnection,SqlTransaction);
2.SqlCommand类的三个方法:
1.ExecuteNonQuery();它的返回值类型为int型。多用于执行增加,删除,修改数据。返回受影响的行数。
2.ExecuteReader();它的返回类型为SqlDataReader。此方法用于用户进行的查询操作。使用SqlDataReader对象的Read();方法进行逐行读取。
例如:
SqlCommand comm =new SqlCommand("select * from CGSZ where cid="+id,conn);
SqlDataReader reder=comm.ExecuteReader();
while(reder.Read())
{
//读出内容列
string str=reder["cname"].ToString();
//读取分类列
string str1=reder["ckind"].ToString();
//分别为文本框加载数据
this.txtContent.Text = str;
this.txtClass.Text = str1;
}
3.ExecuteScalar();它的返回值类型多为int类型。它返回的多为执行select查询。得到的返回结果为一个值的情况,比如使用count函数求表中记录个数或者使用sum函 数求和等。
3.SqlCommand类的四个属性:
1.CommandText,获取或设置要对数据源执行的Transact—SQL语句或存储过程。
2.CommandType,获取或设置一个值,该值指示如何解释CommandText属性。
3.Connection,获取或设置SqlCommand的实例使用的SqlConnection。
4.CommandTimeOut,获取或设置在终止执行命令的尝试并生成错误之前的等待时间。等待命令执行的时时间(以秒为单位)。预设值为 30 秒。
维护基于ASP.NET的网站的学习-SqlCommand类介绍及存储过程的更多相关文章
- ASP.NET Core Web开发学习笔记-1介绍篇
ASP.NET Core Web开发学习笔记-1介绍篇 给大家说声报歉,从2012年个人情感破裂的那一天,本人的51CTO,CnBlogs,Csdn,QQ,Weboo就再也没有更新过.踏实的生活(曾辞 ...
- 【jqGrid for ASP.NET MVC Documentation】.学习笔记.1.介绍
1 介绍 jqGrid for ASP.NET MVC 是一个服务端组件. 专为MVC 分隔 model ,view , controller 的原则,完全观察者模式 非常快的速度 仅仅很 ...
- asp.net core 系列 2 启动Startup类介绍
一.Startup类 ASP.NET Core 应用是一个控制台应用,它在其 Program.Main 方法中创建 Web 服务器.其中Main方法是应用的托管入口点,Main 方法调用 WebHos ...
- 基于asp.net + easyui框架,一步步学习easyui-datagrid——实现分页和搜索(二)
http://blog.csdn.net/jiuqiyuliang/article/details/19967031 目录: 基于asp.net + easyui框架,一步步学习easyui-data ...
- 基于Flask框架搭建视频网站的学习日志(一)
------------恢复内容开始------------ 基于Flask框架搭建视频网站的学习日志(一)2020/02/01 一.Flask环境搭建 创建虚拟环境 初次搭建虚拟环境 搭建完虚拟环境 ...
- 基于Flask框架搭建视频网站的学习日志(二)
基于Flask框架搭建视频网站的学习日志(二)2020/02/02 一.初始化 所有的Flask程序都必须创建一个程序实例,程序实例是Flask类的对象 from flask import Flask ...
- 基于Flask框架搭建视频网站的学习日志(三)之原始web表单
基于Flask框架搭建视频网站的学习日志(三)1.原始Web 表单 本节主要用于体验一下前端后端直接数据的交互,样例不是太完善,下一节会加入Flash处理,稍微完善一下页面 (备注:建议先阅读廖雪峰老 ...
- (一)学习了解OrchardCore笔记——开篇:基于asp.net core的OrchardCore
想深入了解OrchadCore源码许久了,但是读源码的时候遇到很多问题而网上的参考资料太少了(几乎都是OrchadCms不带OrchardCore的),现在解决得差不多了,做下笔记方便自己查看,有错误 ...
- 基于SageMath的数学网站——本科毕业开发项目
1 绪论 1.1研究背景 我国是一个拥有15亿人口的大国.其中,据2017年的统计,全国共有大学生2600万左右.如此数量众多的大学生,都会有着学习基础数理课程的需求.而在高校的数学教学中,教授最多最 ...
随机推荐
- Docker入门到实践——简单操作
1.对比传统虚拟机总结 特性 容器 虚拟机 启动 秒级 分钟级 硬盘使用 一般为MB 一般为GB 性能 接近原生 弱于 系统支持量 单机支持上千个容器 一般几十个 2.基本概念 Docker包括三个基 ...
- 松软带你学开发-SQLSELECTDISTINCT语句
SQL SELECT DISTINCT 语句 在表中,可能会包含重复值.这并不成问题,不过,有时您也许希望仅仅列出不同(distinct)的值. 关键词 DISTINCT 用于返回唯一不同的值. 语法 ...
- Nginx正确配置Location
文章原创于公众号:程序猿周先森.本平台不定时更新,喜欢我的文章,欢迎关注我的微信公众号. 之前已经讲过Nginx的基本配置,本篇文章主要对Nginx中Location指令的作用进行介绍.本篇文章主要对 ...
- 亮剑.NET学习札记
学习前提要: 因为书的版本过老,有些章节不学了,要学的包括以下章节 暂定:1,2,4,5,6,7,9,10,11,12,13,14,15,16,17,18,附录A 第一章:主要是介绍.NET,包括面向 ...
- 实践APP安全性检测(一):APK反编译
1.概述 APP安全性一般可以从以下几方面进行考量: 以及其他一些杂项(或者通用并不局限于APP的安全项): 本文讨论反编译问题. 2.APK反编译 安卓开发的APP,如果不做任何处理是很容易被反编译 ...
- [Link 2005]vs2015 LNK2005 "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl printR(class std::basic_ostream<char,struct std::char_traits<char> > &,class QueryResult const &)" (?
vs2015 LNK2005 "class std::basic_ostream<char,struct std::char_traits<char> > &am ...
- 【ADO.NET基础-GridView】GridView的编辑、更新、取消、删除以及相关基础操作代码
代码都是基础操作,后续功能还会更新,如有问题欢迎提出和提问....... 前台代码: <asp:GridView ID=" OnRowDataBound="GridView1 ...
- 更该clover软件图标(任务栏显示)
1.首先介绍一个Clover软件,Clover 的功能就是给资源管理器加上 Chrome 一样的标签页,像下面这样,你会爱上它的效率,和浏览器一样的操作方式. 2.它自带的系统图标比较丑(虽然作者说挺 ...
- CSS技巧(1)· CSS渐变 linear-gradient
前言: 不论在网页设计中,还是传统的媒介中,各种尺寸,颜色,角度的图案在视觉中无处不在,要想在网页中实现复杂的图案,其过程往往不够理想,过去,我们可以创建一个单独的位图文件,然后每次需要做调整的时候, ...
- js赋值,字典,数据类型和参数传递的简单熟悉
之所以这样分,原因是布尔类型和整数浮点数在内存里是直接赋值的,而数组实际上数组名指的是这个数组的地址 字符串同样是地址,字典也是. //熟悉赋值 var x=0; console.log(x); va ...