- 博客(310)
- 资源 (3)
- 收藏
- 关注
原创 SQLServer -- 事务的应用
在存储过程的应用--use StudentManager--go----事务基本框架--declare @errorSum int --定义变量,用于累计事务执行过程中的错误--set @errorSum =0 --初始化为0,即无错误--begin transaction-- begin-- update CardAccount set CurrentMoney=Curre
2017-09-03 23:55:51
339
原创 SQLServer--事务的创建
基本框架use StudentManagergo--事务基本框架declare @errorSum int --定义变量,用于累计事务执行过程中的错误set @errorSum =0 --初始化为0,即无错误begin transaction begin if(@errorSum>0) rollback transaction
2017-09-03 22:37:44
7879
1
原创 SQLServer--带输出参数的存储过程
带输出参数的过程use StuManageDBgo if exists(select * from sysobjects where name='usp_ScoreQuery3')drop procedure usp_ScoreQuery3gocreate procedure usp_ScoreQuery3@AbsentCount int output,@FailedCount int
2017-09-03 10:23:53
8954
原创 SQLServer --自定义带输入参数的存储过程
带输入参数的存储过程在参数中添加默认值use StuManageDBgoif exists(select * from sysobjects where name='usp_ScoreQuery1')drop procedure usp_ScoreQuery1gocreate procedure usp_ScoreQuery1--参数自定义默认值@CSharp int=60,@DB int
2017-09-03 09:16:45
28139
原创 SQLServer -- 自定义无参数存储过程
自定义储过程use StuManageDBgoif exists(Select * from sysobjects where name='usp_ScoreQuery')drop procedure usp_ScoreQuerygocreate procedure usp_ScoreQuery --创建存储过程as --查询考试信息 select Students.Stu
2017-09-03 08:02:56
4297
原创 在Windows运行Python程序
IDLE的文件编辑器运行程序运行它很简单!!!但打开idle来运行已完成的程序有点累。执行Python脚本还有更方便的方法第一行: 在Windows上,第一行是 #! python3。 在OS X,第一行是 #! /usr/bin/env python3。 在Linux上,第一行是 #!/usr/bin/python3。 提示: 没有#!行,能从idle运行p
2017-09-02 05:57:51
5822
原创 SQLServer--常用的扩展存储过程使用
创建文件目录use master go exec xp_cmdshell 'mkdir D:\ProductDB',no_output --在指定位置创建文件夹if exists(select * from sysobjects where name='ProductDB')drop database ProductDBgoexec xp_cmdshell 'dir D:\Product
2017-08-31 03:47:58
1852
原创 SQLServer--常用的系统存储过程使用
常用存储过程有哪些??存储过程调用方法提示:EXECUTE可以简写称EXECsp_databases --列出系统当前的数据库exec sp_renamedb 'SharkDB','SharkDB1' --修改数据库的名称use StuManageDBgosp_tables --当前数据库中查询的对象的列表exec sp_columns Students --返回Students列表的
2017-08-31 03:32:34
630
原创 SQLServer--存储过程的概念理解
什么是存储过程管理器应用的查看方式:由此可见,视图,也完全可以通过编写存储过程来实现。但视图只能是查询,而存储过程里面可以包含增、删、改、查很多内容,可以非常复杂。这是俩者的区别。存储过程的优点总结应用程序发送SQL语句与调用存储过程或视图过程对比通过对比,可以看到后者传递参数可以立即执行,而SQL语句的执行过程非常复杂。
2017-08-31 02:25:08
547
原创 SQLServer--使用T-SQL语句创建视图、删除视图、查看视图
使用T-SQL语句操作视图提示:只能查看,删除,创建视图,不能对数据进行增,删,改操作。use StuManageDBgo--判断视图是否存在if exists(Select * from sysobjects where Name='View_ScoreQuery')drop view View_ScoreQuerygo--创建视图create view View_ScoreQuer
2017-08-31 01:31:36
31121
1
原创 SQLServer--视图的创建与使用
使用企业管理器Management Studio创建视图选择要添加的表选择要添加的列:然后输入视图文件名、保存视图表查询刚新建的视图表:视图中的查询与普通查询完全一样。
2017-08-31 00:20:51
1776
2
原创 SQLServer--EXISTS与NOTEXISTS子查询
EXISTS 与 NOT EXISTS提示:如果子查询的结果非空,即记录条数1条以上,则Exists(子查询)将返回真(true),否则返回假(false)--如果有一条不超过66分显示考试比较难,否则比较适合if exists(Select * from ScoreList where CSharp<66) print '本次考试内容较难'else print '本次考试比较
2017-08-30 19:24:00
2953
原创 SQLServer--IN子查询与NOT IN子查询的用法
IN子查询–使用IN后面的子查询可以返回多条记录。常用IN替换等于(=)的比较子查询 NOT IN子查询--使用IN后面的子查询可以返回多条记录。常用IN替换等于(=)的比较子查询Select StudentName from Students where StudentId IN(Select StudentId from ScoreList where SQLServerDB>80)--查
2017-08-30 15:27:28
14972
原创 SQLServer--简单子查询
子查询的使用use StuManageDBgo--使用变量方式实现declare @StuId intSelect @StuId=StudentId from Students where StudentName='张永利'Select StudentName,Gender,Age from Students where StudentId>@StuId--使用子查询实现Select S
2017-08-30 14:50:11
4758
1
原创 SQLServer--逻辑控制语句
IF-ELSE语句ELSE是可选部分,如果有多条语句,才需要BEGIN-NED语句块。use StuManageDBgodeclare @cAvg intSelect @cAvg=avg(CSharp)from ScoreListinner join Students on ScoreList.StudentId=Students.StudentId where ClassId=1Prin
2017-08-30 04:28:31
2511
原创 SQLServer--T-SQL中的其他函数
datediff函数计算俩个日期差floor函数返回一个小于或等于当前值的最大整数use StuManageDBgo--定义变量declare @birthday datetime,@days int ,@age int--查询出生日期Select @birthday=Birthday from Students where StudentId=100002--计算出生天数set @d
2017-08-30 03:09:24
286
原创 SQLServer -- 数据类型转换
字符串和数值不能直接相加使用数据类型转换数据类型转换应用use StuManageDBgo--使用CAST转换Select StudentName +'的出生日期是'+CAST(Birthday as varchar(50)) as '学生信息'from students where StudentId=100005Select StudentName +'的出生日期是'+CONVERT(v
2017-08-30 01:58:12
2362
原创 SQLServer--变量的使用
变量的定义与使用局部变量:(仅在过程中使用)必须以标记@作为前缀,如@age,同样要求先声明(使用 declare ),再赋值。这是编程中经常要自己定义的变量类型。use StuManageDBgo--声明学号变量declare @stuId int,@stuName varchar(20)--查询李铭的信息set @stuName = '李铭'select StudentId,Stud
2017-08-29 22:32:32
13610
原创 SQLServer--给数据库用户授权与角色管理
给数据库用户授权1–授权、查,增,改的方法use StudentManageDBgo--分配权限grant select,insert,Update on Students to sharkUser01grant create table to sharkUser01发现可以对查、增、改操作,但是不能执行删除操作。回收数据库用户权限use StudentManageDBgo--回收权限r
2017-08-29 12:45:30
36148
原创 SQLServer - 删除登录账号、数据库用户
删除登录账号、SQL用户use master --删除登录账号goexec sp_droplogin 'SqlShark' --登录名use StudentManageDB --删除数据库用户goexec sp_dropuser 'sharkUser01' --数据库名
2017-08-29 11:44:59
15299
原创 SQLServer-添加数据库用户
创建完了登录用户,但是还是不能登录数据库用户 因此要创建数据库用户添加数据库用户use StudentManageDBgo exec sp_grantdbaccess 'SqlShark','sharkUser01'exec sp_grantdbaccess 'SHARK2\Shark','winDowsSharkUser01'
2017-08-29 06:30:59
919
原创 SQLServer2016--添加登录账号、后续练习脚本
登录验证方式介绍SQLServer身份验证:适合于非Windows平台的用户或Interner用户,需要提供账户和密码。 Windows身份验证:适合与windows平台用户,不需要提供密码,和Windows集成验证。创建多个Windows登录账号的方法在本机计算创建多个Windows账号例如-要使用Shark的Windows账号登录数据库:use mastergoexec sp_grant
2017-08-29 05:29:42
9350
1
原创 C# - WinForm-学员对象删除
删除学员对象示例后台删除方法 /// <summary> /// 删除学员对象 /// </summary> /// <param name="studentId"></param> /// <returns></returns> public int DeleteStuent(string studentId)
2017-08-29 02:42:55
928
原创 C#-WinForm-实现学员对象修改
实现学员对象修改示例查询学员对象-获取DataGridView学员Id 进行跳出窗体修改对像后台修改对象方法 /// <summary> /// 修改学员对象 /// </summary> /// <param name="objStu"></param> /// <returns></returns> public i
2017-08-29 01:17:07
954
原创 c#-WinForm-按照学号精确查询对象
学号精确查询示例后台查询方法/// <summary> /// 根据学号查询学员对象 /// </summary> /// <param name="stuId"></param> /// <returns></returns> public StudentExt GetStudnetById(string stuId)
2017-08-27 06:38:00
2843
原创 c#--WinForm-查询结果的排序
自定义排序类 //自定义排序类 class NameDESC : IComparer<StudentExt> { //按照姓名降序 public int Compare(StudentExt x, StudentExt y) { return y.StudentName.CompareTo(x.StudentNa
2017-08-27 01:09:44
950
原创 C#-WinForm-DataGridView展示查询结果
DataGridView根据学员班级查询后台方法前台学员班级查询方法DataGridView禁止生成不需要的列this.dgvStudentList.AutoGenerateColumns = false;
2017-08-27 00:24:13
6035
1
原创 C#-WinForm班级下拉框数据绑定
前天展示后台方法using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Data;using System.Data.SqlClient;using Models;namespace DAL{ public class StudentClass
2017-08-26 22:34:04
16925
1
原创 C#--两层架构基于OOP实现对象添加到数据库
准备的工作俩层架构的框架1-数据访问层—DAL;2-实体类—Models; 3-UI层—StudentManagePro;总体架构展示:SQL表:UI界面展示编写后台方法StudentService.csusing System;using System.Collections.Generic;using System.Linq;using System.Text;using Models
2017-08-24 04:57:07
1166
原创 c#--将图片转换为二进制序列字符串
引入三个命名空间将Object类型对象(注:必须是可序列化的对象)转换为二进制序列字符串将二进制序列字符串转换为Object类型对象using System;using System.Collections.Generic;using System.Linq;using System.Text;//引入三个命名空间using System.Runtime.Serialization;usi
2017-08-24 02:55:58
2609
1
原创 C#--添加对象前 - 身份证号的验证
验证是否符合通用验证类的要求调用通用验证类 通过数据验证 验证身份证号是否存在SQL如果SQL有了身份证信息新增的身份证号不能是重复的 编写查询身份证方法 /// <summary> /// 查询身份证是否已经存在 /// </summary> /// <param name="idcard"></param> /// <re
2017-08-24 02:05:08
381
原创 C#--添加对象之前的数据验证
添加对象之前的数据验证 //添加新学员 private void btnAdd_Click(object sender, EventArgs e) { //数据验证 if(this.txtStuName.Text.Trim().Length==0) { Messag
2017-08-23 11:21:13
595
原创 C#--WinForm图片选择对话框的使用
程序图片对话框的使用 //选择照片 private void btnChoseImage_Click(object sender, EventArgs e) { OpenFileDialog fileDialog = new OpenFileDialog(); DialogResult result = fileDial
2017-08-23 10:20:57
9361
原创 C#--应用程序版本号发布配置
程序的版本号设置主程序引入命名空间App.config配置文件添加配置代码<appSettings> <add key="sysversion" value ="2.2.0.1"/> </appSettings>----------## 主程序初始化 添加--- ##![这里写图片描述](http://img.blog.csdn.net/20170822235120979?waterm
2017-08-22 23:52:37
4522
原创 C#-WinForm应用程序退出设计方法
应用程序关闭询问防止用户点击立马退出程序。 调用窗体关闭前事件: //窗体关闭前事件 private void FrmMain_FormClosing(object sender, FormClosingEventArgs e) { DialogResult result = MessageBox.Show("确认退出吗?", "退出询问
2017-08-22 03:42:50
1132
原创 c#-WinFrom子窗体嵌入主窗体
示例添加嵌入按钮事件代码复用OOP原则解决多个按钮快速编写窗体嵌入 符合面向对象编程方法 独立出打开窗体的方法: //打开窗体方法 private void OpenFrom(Form objFrm) { //将当前子窗体设置成非顶级控件 objFrm.TopLevel = false;
2017-08-22 03:10:42
21546
11
原创 C#-通用数据验证类
引入通用验证类命名控件using System.Text.RegularExpressions; 验证是否正整数验证是否Email验证身份证using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Text.RegularExpressions;namespa
2017-08-22 01:32:52
4077
原创 c#-通用数据访问类SQLHelper编写
更新数据操作获取单一结果集返回一个结果集的查询using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Data;using System.Data.SqlClient;using System.Configuration;namespace DAL{
2017-08-21 03:46:48
842
C#--Winfrom 俩层框架 学生管理系统 数据库练习脚本
2017-09-07
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人