Title: ?? ADO????
1?? ADO????
2????
- ????ADO?????,?????ASP?????ADO????
- ??ADO???Connection?RecordSet?Command????
- ??????SQL??????????????????????
3??????????
- ODBCOpen DataBase Connection???????
- OLE-DB?ODBC???,???,???????,???
- ADO????,?OLE-DB???,???,??????????????????????????
4ADO??
- ADO????Connection?Command?Parameter?RecordSet?Fiel
d?Property?Error??????Fields?Properties?Parameters
?Errors????????????,??????? - Connection?????????????????????
- Command????????SQL??,????????
- Parameter???Parameters?????Command???????SQL????
? - RecordSet??????????????,????????
- Field???Field???????RecordSet???????????????????
? - Property???Properties????????????,?Connection?Co
mmand?RecordSet?Field????? - Error???Errors??????????????????
- ??????Connection?RecordSet?Field?Command?
??
5Connection??
- ?????????????????Connection???????????????????????
,???????????
6Connection????????
7Connection?????
8???????
- OLE-DB??????ADO???ConnectionString??
- ??MS Access???????
- set connServer.createobject("ADODB.Connection")
- conn.connectionstringProviderMicrosoft.Jet.OLE
DB.4.0Data Source Server.Mappath("student.mdb
") - conn.open
- '???student.mdb???
9Connection??????
- ?????OLympic.html
- ????Access???olympic.mdb
- ????????games
- ?????????gl.asp
- ????????,????,????
10RecordSet??
- RecordSet???????????????????????,?????????
- ??RecordSet???????????????????,?????SQL?????????
11RecordSet?????
12RecordSet?????
13RecordSet??????
- ?????????,???RecordSet??,????open????RecordSet??
- '????
- set connServer.createobject("ADODB.Connection")
- conn.connectionstring"ProviderMicrosoft.Jet.O
LEDB.4.0Data Source" Server.Mappath("olympic.m
db") - conn.open
- '??Recordset??
- set rsServer.createobject("ADODB.Recordset")
- sqlstr"select from games"
- rs.open sqlstr,conn
14???????
15RecordSet??????
- ??1??????????
- ????rfields.asp
- ??2??????
- ????move.asp
16?????????
- (1)adOpenFowardOnly??????0(???),?????????????????
??,????????Adovbs.inc?? - (2)adOpenKeyset??????1,??????????????????????????
???,??????????????,??????????????,????????????? - (3)adOpenDynamic??????2,??????,??????????????????
??????????????????????? - (4)adOpenStatic???????3,??????,?????????????????,?
??????????????????????
17Command??
Connection?????????????????, Recordset???????????
???????????,Command??????????????SQL???????? ???C
ommand??,???????????????SQL???????,?????????
(1)??SQL?Select??,??????,????????Recordset???? Se
t rs Conn.Execute(Select??)
(2)??SQL?Insert?Delete?Update??,??????? Conn.Exec
ute SQL??????? (3)???Recordset??,???SQL??? Se
t rs Server.CreateObject("ADODB.Recordset") rs.
Open SQL??,Conn
18Command??
??,????????Connection?????SQL??,??????????
Recordset?????SQL?????,??Command?????????SQL???
Command???SQL??????????????,?????????SQL????
??????,??????????SQL??,??????????????(?????,???SQL
??)???Command????SQL?Select???,???Recordset???????
?????,??????????????,??????Recordset???Open???????
?? ??Command?????? Set Command???
Server.CreateObject("ADODB. Command")
19Command????????
20Command???????
21??Command??
- ??Command?????SQL ??,??adocmd.asp?