摘要:
View Code using System;using System.Data;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;/// <summary>/// visit 的摘要说明/// </summary>public cl 阅读全文
posted @ 2012-06-24 16:34
ComBat
阅读(152)
评论(0)
推荐(0)
摘要:
View Code 分页 排序等using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;public partial class 分页_Default : System.Web.UI.Page{ int pagesize = 10; protected void Page_Load(object sender, EventArgs e) { ViewSta... 阅读全文
posted @ 2012-06-24 15:53
ComBat
阅读(171)
评论(0)
推荐(0)
摘要:
View Code using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Text.RegularExpressions;/// <summary>///SQLInjectionHelper 的摘要说明/// </summary>public class SQLInjectionHelper{ public SQLInjectionHelper() { // //TODO: 在此处添加构造函数逻辑 // ... 阅读全文
posted @ 2012-06-24 15:16
ComBat
阅读(217)
评论(0)
推荐(0)
摘要:
View Code <style type="text/css"> body,ul,div,li { margin:0; padding:0px; } #dhl { width:960px; height:35px; background:#ccc; margin:40px auto 0; line-height:35px; } #dhl ul li { float:left; } #dhl a { display:block;... 阅读全文
posted @ 2012-06-24 15:10
ComBat
阅读(224)
评论(0)
推荐(0)
摘要:
View Code IE6 版本无效果 不支持CSS代码段——————————————————————————————————body,div,ul,li,a{ margin:0; padding:0}#dhl{ height: 34px; margin: 0; padding: 0; background-color: #66cccc; }#dhl ul{ list-style:none}#dhl ul li{ float:left; padding-left:20px; margin:0px}#dhl ul li a{ display:block; line-height:34px; ma 阅读全文
posted @ 2012-06-24 15:08
ComBat
阅读(204)
评论(0)
推荐(0)
摘要:
View Code string fullFileName = this.FileUpload1.PostedFile.FileName; //全路径 string fileName = fullFileName.Substring(fullFileName.LastIndexOf("\\") + 1); // 这是\ 后面的名字 string type = fullFileName.Substring(fullFileName.LastIndexOf(".") + 1); //这是.后面的名字 记得要加1 if ... 阅读全文
posted @ 2012-06-24 15:04
ComBat
阅读(133)
评论(0)
推荐(0)
摘要:
表名 字段名 请尽量少用关键字如 Admin,password,user等表名加[]中括号,格式尽量要求严谨1.标准表达式中数据类型不匹配找了半天 原来是参数顺序的问题,纠结!access在用OleDbParameter的时候要注意SQL语句中参数和cmd.Parameters.Add()增加的参数的顺序对应其实大家保持良好的书写代码习惯,能够尽程度排除错误! 阅读全文
posted @ 2012-06-24 15:01
ComBat
阅读(201)
评论(0)
推荐(0)
摘要:
View Code using System;using System.Data;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data;using System.Data.OleDb;/// <summary>// 阅读全文
posted @ 2012-06-24 14:18
ComBat
阅读(251)
评论(0)
推荐(0)
摘要:
View Code web.config 文件————————————————————————————<configuration> <!--连接字符串--> <connectionStrings> <add name="sql2005" connectionString="Data Source=.;Initial catalog=MySchool;uid=sa;pwd=221221"/> </connectionStrings> <system.web> <compilat 阅读全文
posted @ 2012-06-24 14:09
ComBat
阅读(265)
评论(0)
推荐(0)
摘要:
View Code 由于Access是文件数据库,所以在ASP.NET需要能映射访问到Access文件: 方式一:appSettings中设置连接字符串web.config的配置 方式一 <appSettings> <add key="provider" value="Provider=Microsoft.Jet.OLEDB.4.0;data source="/> <add key="dbPath" value="~/App_Data\PF.mdb"/> </appSett 阅读全文
posted @ 2012-06-24 13:43
ComBat
阅读(341)
评论(0)
推荐(0)
摘要:
View Code --模拟转账(事务)begintransactiondeclare @errorSum intset @errorSum=0update Customer set CurrentMoney=CurrentMoney-500where [Name]='张三'set @errorSum=@errorSum+@@errorupdate Customer set CurrentMoney=CurrentMoney+500where [Name]='李四'set @errorSum=@errorSum+@@errorprintconvert(varch 阅读全文
posted @ 2012-06-24 13:30
ComBat
阅读(355)
评论(0)
推荐(0)
摘要:
View Code --创建数据库if exists(select*from sysdatabases where name='school')drop database schoolcreate database schoolon primary( name='school_db', filename='D:\project\school_db.mdf', size=5mb, maxsize=100, filegrowth=15%)log on( name='school_log', filename='D:\proje 阅读全文
posted @ 2012-06-24 13:29
ComBat
阅读(159)
评论(0)
推荐(0)
摘要:
View Code --比较运算符:=、!=、<、<=、>、>=子查询结果必须为个--如果子查询结果大于,请使用in关键字select*from StuInfo where ID in(select StuID from StuMark where WrittenExam=60)--查询参加考试的学生信息select*from StuInfo where ID in(select StuID from StuMark)--查询未参加考试的学生信息select*from StuInfo where ID notin(select StuID from StuMark)-- 阅读全文
posted @ 2012-06-24 13:27
ComBat
阅读(284)
评论(0)
推荐(0)
摘要:
View Code --case...end--ABCDE显示成绩select学号=StuID,成绩=case when WrittenExam<60 then'E' when WrittenExam between 60 and 69 then'D' when WrittenExam between 70 and 79 then'C' when WrittenExam between 80 and 89 then'B' else 'A'endfrom StuMarkselect学号=StuID,笔试成绩=W 阅读全文
posted @ 2012-06-24 13:22
ComBat
阅读(121)
评论(0)
推荐(0)
摘要:
View Code --全局变量,由系统定义(两个@@符)select@@version--局部变量declare @name varchar(8)declare @seat int--变量赋值可以使用关键字:set、selectset @name='张三'select @seat=15--查看变量值select @name as 姓名,@seat 座位号--使用查询语句给变量赋值--将表中id为的姓名赋值给@stuNamedeclare @stuName varchar(50)select @stuName=StuName from StuInfowhere id=4--打印 阅读全文
posted @ 2012-06-24 10:49
ComBat
阅读(132)
评论(0)
推荐(0)
摘要:
View Code --学生成绩表createtable StuMark( ID intprimarykeyidentity(1,1), StuID int, WrittenExam int, LabExam int)--判断表是否存在ifexists(select*from sysobjects wherename='StuMark')droptable StuMark createtable StuMark( ID intprimarykeyidentity(1,1), StuID int, WrittenExam int, LabExam int) --创建主键约束alt 阅读全文
posted @ 2012-06-24 10:44
ComBat
阅读(75)
评论(0)
推荐(0)
摘要:
View Code --建库createdatabase Studentonprimary( name='Student_db',--逻辑名 filename='D:\Student_db.mdf',--物理文件名 size=5mb,--初始化大小 maxsize=100,--最大值 filegrowth=15%--自动增长率)logon( name='Student_log', filename='D:\Student_log.ldf', size=2mb, filegrowth=1mb)--建库(带次要的数据库文件和多个日志文 阅读全文
posted @ 2012-06-24 10:42
ComBat
阅读(145)
评论(0)
推荐(0)
摘要:
View Code --内联接:Whereselect s.SName as姓名,m.Score 成绩fromStudents s,StuMark mwhere s.ID=m.StuID--三表联接查询select s.SName 姓名,m.Score 成绩,c.CourseName 课程fromStudents s innerjoin stuMark mon s.ID=m.StuID innerjoin Courses con c.ID=m.CourseID--左外联接(如果左表存在的数据在右表中不存在以空的方式显示)select s.SName,m.Score fromStudents s 阅读全文
posted @ 2012-06-24 10:40
ComBat
阅读(121)
评论(0)
推荐(0)
摘要:
View Code --求学生信息表:平均年龄、男生总数、最大,最小年龄、学生人数selectavg(Age)平均年龄,sum(convert(int,Sex))男生人数,max(age)最大年龄,min(age)最小年龄,count(*)学生人数from Students--分组统计每种课程的平均分--通常集合函数配合分组来统计数据的--在使用聚合函数时,所指定的列必须是聚合函数列、或--分组所指定的列select CourseID 课程编号,avg(Score)平均分,Sum(Score)总分,max(Score)最高分,min(Score)最低分,count(*)总人数from StuM 阅读全文
posted @ 2012-06-24 10:23
ComBat
阅读(144)
评论(0)
推荐(0)
摘要:
View Code --系统函数--数据类型转换selectconvert(varchar(5),12345)selectconvert(int,'12345')--当前数据库用户selectcurrent_user--返回字符的字节数selectdatalength('中华人民共和国')--返回当前OS的计算机名selectHost_Name()--当前SQLSever的登录名selectsystem_user--根据指定数值获取当前数据的用户名selectuser_name(1)selectuser_name(2)selectuser_name(3)sele 阅读全文
posted @ 2012-06-24 10:21
ComBat
阅读(153)
评论(0)
推荐(0)
摘要:
View Code --字符串函数:--返回指定字符串的索引,索引从开始,返回一个索引(int类型)selectcharindex('niit','Welcome to niit')selectcharindex('niit','Welcome to niit',8) --返回字符串的长度(返回字符个数非字节个数)selectlen('SQLServer2005编程') --将大写字符串转换为小写selectlower('SQLSERVER') --清除字符左边空格selectltrim(' 阅读全文
posted @ 2012-06-24 10:14
ComBat
阅读(106)
评论(0)
推荐(0)
摘要:
View Code --向子表中插入外键列数据时,在主表中必须存在--否则将违反外键约束--如果在子表中存在关联主表中的数据,那么删除主表--会违反外键约束,无法删除,如果一定要删除主表中的--数据,应先将子表中的数据删除后再删除主表中的数据--delete语句删除表标识列不会重新编号deletefrom StuBak--truncate语句删除表会重新编号标识列--注:不能用于有外键约束的表truncatetable StuBak--指定列名查询表的信息select SName,Age,Address from Students--取别名查询表的信息select SName as姓名,Age 阅读全文
posted @ 2012-06-24 10:11
ComBat
阅读(187)
评论(0)
推荐(0)
摘要:
View Code 可靠+准确=数据完整性实体完整性(主键):确保表中的数据是唯一的.域完整性(检查约束):确保表中的列值是一个有效的数据范围引用完整性(外键):保证关联表中不会出现无效的数据自定义完整性:我们可以通过用户自定义:规则、存储过程、触发器来保证数据的完整性--使用指定的数据库use Students--查询语句select:查询,*:所有列,from:从哪个表select*from Students--插入语句insertinto Students (SName,Age,Sex,SEmail,IdentityCard,Address)values('张三',20, 阅读全文
posted @ 2012-06-24 10:08
ComBat
阅读(132)
评论(0)
推荐(0)

浙公网安备 33010602011771号