上一页 1 2 3 4 5 6 7 ··· 9 下一页
摘要: 表名 字段名 请尽量少用关键字如 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) 编辑
上一页 1 2 3 4 5 6 7 ··· 9 下一页