课13
读取表字段名称和数目
Fields集合
Fields.count--------表字段的数目
Field.Name--------字段名称
Field.Value---------字段值
page 269
一、数据库查询
SQL查询
用例子来看看SQL的用发 page282
将打开数据库包含到函数里
Function GetSQLRecordset(strSQL,FileName)
set objConn=Server.CreateObject("ADODB.Connection")
objConn.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;"&_
"Data Source=" & Server.MapPath(FileName)
objConn.open
set GetSQLRecordset=Server.CreateObject("ADODB.recordset")
GetSQLRecordset.open strSQL,objConn,1,3
end Function
二、SQL语法:
1、筛选数据 SELECT
Select 条件
From 表名称
[where 搜索子句]
[Order By 排序字句 [ASC | DESC]
page285
2、where 语法
逻辑运算 和比较运算
> OR
< AND
<> NOT
3、Like运算
%---------任何长度字符串
_ ----------任何一个字符
[] ---------某个范围内的一个字符
select * from table1 where 姓名 Like '陈%'
select * from table1 where 姓名 Like '_小美'
select * from table1 where 姓名 Like '[a-f]ean'
select * from table1 where Mid(姓名,1,1)='陈'
select * from table1 where (数学 IS NULL) AND (语文 IS NOT NULL)
select * from table1 where 语文 in (80,85,90)
select * from table1 where 姓名 in ('陈小新','陈军容','孙小美')
select 姓名,语文,数学 from 成绩单 where 数学 Between 80 And 90
4、ORDER BY语法
select * from 成绩单 Order By 语文 ASC (递增)
5、TOP语法
select Top 5 * from 成绩单 Order By 语文 DESC
6、Connection 的Execute方法
page 292
7、增加
Insert Into 表名称 (字段1,字段2,字段3...) Values(数据1,数据2,数据3)
page 295
8、更新
Update 表名 Set 字段1=数据1,字段2=数据2,字段3=数据3 where 条件
page 296
9、删除
Delete * From 表名 Where 条件 page 297
关系数据库的例子
Fields集合
Fields.count--------表字段的数目
Field.Name--------字段名称
Field.Value---------字段值
page 269
一、数据库查询
SQL查询
用例子来看看SQL的用发 page282
将打开数据库包含到函数里
Function GetSQLRecordset(strSQL,FileName)
set objConn=Server.CreateObject("ADODB.Connection")
objConn.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;"&_
"Data Source=" & Server.MapPath(FileName)
objConn.open
set GetSQLRecordset=Server.CreateObject("ADODB.recordset")
GetSQLRecordset.open strSQL,objConn,1,3
end Function
二、SQL语法:
1、筛选数据 SELECT
Select 条件
From 表名称
[where 搜索子句]
[Order By 排序字句 [ASC | DESC]
page285
2、where 语法
逻辑运算 和比较运算
> OR
< AND
<> NOT
3、Like运算
%---------任何长度字符串
_ ----------任何一个字符
[] ---------某个范围内的一个字符
select * from table1 where 姓名 Like '陈%'
select * from table1 where 姓名 Like '_小美'
select * from table1 where 姓名 Like '[a-f]ean'
select * from table1 where Mid(姓名,1,1)='陈'
select * from table1 where (数学 IS NULL) AND (语文 IS NOT NULL)
select * from table1 where 语文 in (80,85,90)
select * from table1 where 姓名 in ('陈小新','陈军容','孙小美')
select 姓名,语文,数学 from 成绩单 where 数学 Between 80 And 90
4、ORDER BY语法
select * from 成绩单 Order By 语文 ASC (递增)
5、TOP语法
select Top 5 * from 成绩单 Order By 语文 DESC
6、Connection 的Execute方法
page 292
7、增加
Insert Into 表名称 (字段1,字段2,字段3...) Values(数据1,数据2,数据3)
page 295
8、更新
Update 表名 Set 字段1=数据1,字段2=数据2,字段3=数据3 where 条件
page 296
9、删除
Delete * From 表名 Where 条件 page 297
关系数据库的例子

浙公网安备 33010602011771号