摘要: 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 阅读(147) 评论(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 阅读(166) 评论(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 阅读(212) 评论(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 阅读(219) 评论(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 阅读(196) 评论(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 阅读(127) 评论(0) 推荐(0) 编辑
摘要: 表名 字段名 请尽量少用关键字如 Admin,password,user等表名加[]中括号,格式尽量要求严谨1.标准表达式中数据类型不匹配找了半天 原来是参数顺序的问题,纠结!access在用OleDbParameter的时候要注意SQL语句中参数和cmd.Parameters.Add()增加的参数的顺序对应其实大家保持良好的书写代码习惯,能够尽程度排除错误! 阅读全文
posted @ 2012-06-24 15:01 ComBat 阅读(194) 评论(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 阅读(244) 评论(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 阅读(256) 评论(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 阅读(331) 评论(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 阅读(351) 评论(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 阅读(155) 评论(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 阅读(269) 评论(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 阅读(114) 评论(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 阅读(123) 评论(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 阅读(73) 评论(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 阅读(138) 评论(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 阅读(109) 评论(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 阅读(132) 评论(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 阅读(146) 评论(0) 推荐(0) 编辑