Title: ASP??????
1ASP??????
2???
- ??????????
- ??asp?????
- ???????
- ??ASP?????
3??????????
- ????????
- HTML?? (?)
- Vbscript?????
???
41?????????
- ??????????
- ????????????
- ??????????
- ASP??
???? ???
5??????????
6????????????
- ??????????????????????,????????????????????????
??,?????HTML?????????????????,????????? - ?????????????????????????,????????????????HTML??
?????????
????
7??????????
8Active server page
????????
- Asp???????????????,???????,????WEB????????????????
?,??????????WEB????PWS?IIS?APACHE?? - ASP???????.asp?ASP???????????????,????VBSCRIPT?jsc
ript????????WEB??????????
????
9?????????
- ??
- TCP/IP??
- PWS?IIS
- ???127.0.0.1?????IP??,???LOCALHOST?
????
10WEB?????????
????
11??????
- ???
- Frontpage
- Dreamwaver
- Visual interdev
- Editplus
????
12?????asp??
- lt!--???html??,?????????!???????--gt
- ltp align"center"gtltfont size7
colorredgt????????!lt/fontgtlt/pgt - ltp align"center"gt?????????
- lt'??????????
- '????????????????shijian
- Shijiannow
- '????????????
- response.write shijian gt
- ltscript language"vbscript"gt
- lt!--'?????????
- msgbox "????????!"
- --gt
- lt/scriptgt
13Asp????
- Asp???????
- Asp????????????
- ???HTML???
- ?????script????,??lt gt??
- ????script????,??ltscript languagescript??gtlt!--
--gtlt/scriptgt??
14Asp?????
- ???????????script????????ltgt????,???????script???
?????ltscript languagescript??gtlt!--
--gtlt/scriptgt??? - Asp?????????vbscript,???????????????????lt_at_languag
ejavascriptgt ???
15??asp????????
- ?????????
- ???????????????,????????????????????
- Asp????????,???????
- ?????????,???????,???????
- ????????,???????????
- ????????,?????????????????????????????
162?vbscript?????
- ??????????
- ?????
- ???
- ???????
- ????
- ??????
???
17??????????
- ????,Vbscript?????????,??variant(????),????????,??
????????????,?? - 1?empty
- 2?null
- 3?boolean
- 4?byte
- 5?integer
- 6?long
- 7?single
- 8?double
- 9?date(time)
- 10?object
- 11?error
- ?????,variant???????????????,????????????????
?
???? ???
18??????????
- ????
- const const_pi3.1415926 ?PI3.1415926,???????
??? - ?????
- 1?????
- ??dim a ????a ?? dim a,b,c ???????,??
- 2?????
- var_a2 ???????,??????????????,??????????
- 3 ???????
- ???????ltoption explicitgt?????
- ????????????????????????,?????????????,??????????
????,???vbscript????,?????255?????????????????????
????
???? ???
19?????
- Dim name(????-1)
- ??ARRAY???????
- ?????array(???1,???2,,???n)
- ??????
- ?Dim a() ?redim a(n) n??????????????.????????
??????dim(n),n???. - ????
- Dim name(n-1,m-1)
???? ???
20???
? ???? ?
?? ?? ?? ?? ?? ?? ?? ?? ?? ??
?? ?? ?? - ?? ,/ \ ???? \ ???? MOD??? MOD??? ?-
?? ? ?????,????????? ? ?????,????????? ? ?????,????????? ? ?????,????????? ? ?????,????????? ? ?????,????????? ? ?????,????????? ? ?????,????????? ? ?????,?????????
?? ?gt ?lt ?gt ?lt ?ltgt ?like ?is?????,????????? ?gt ?lt ?gt ?lt ?ltgt ?like ?is?????,????????? ?gt ?lt ?gt ?lt ?ltgt ?like ?is?????,????????? ?gt ?lt ?gt ?lt ?ltgt ?like ?is?????,????????? ?gt ?lt ?gt ?lt ?ltgt ?like ?is?????,????????? ?gt ?lt ?gt ?lt ?ltgt ?like ?is?????,????????? ?gt ?lt ?gt ?lt ?ltgt ?like ?is?????,????????? ?gt ?lt ?gt ?lt ?ltgt ?like ?is?????,????????? ?gt ?lt ?gt ?lt ?ltgt ?like ?is?????,?????????
?? Not? And? And? Or? Or? Xor?? Eqv?? Imp?? Imp??
? ? ? ? ? ?
???? ???
21????
?? ?? ?? ??
???? ???? ????????????????.
????? AASP ????????ASP??????.
???? A2004/5/5 ???????2004/5/5???????
_ ????? Aa _ sp ???????????????.??_??????????????.
???? ???
22Vbscript??
- ?????????????????????,??????????????
- ?????vbscript??
- ????
- Cstr(variant)???????????
- Cdate(variant)??????????
- Cint(variant)??????????
232??????
- Len(string)??????????
- Trim(string)???????????
- Mid(string,start,length)?string????start??????leng
th??????? - Lcase(string)???????????
- Ucase(string)???????????
242??????
- 6?Replace(string1,find,replacewith)?????,?????????
??(find)???????????(replacewith) - 7?Strcomp(string1,string2)???????,???1?2?null???nu
ll,???1??2???-1,??2???1,??2???0? - 8?Instr(string1,string2)?????2?????????,????0
253????????
- Date()????????
- Time()????????
- Now()????????????
- Weekday(date)??????????1?????,?????
264?????
- Int(num)????????num???
- Rnd()????0?1????
- ????????
- ltrandomize ??????,???????????
- numint(10rnd()1) rnd()???????0??1???,??????
??110????????10???1,????? - response.write numgt
- ???1-60???
27????
- ??????
- 1?If ??? then
- ????
- End if
- 2?If ??? then
- ?????
- else
- ?????
- End if
- 3?If ???a then
- ?????
- elseif ???b then
- ?????
- elseif
-
- End if
- 4?If ???a then
- if ???b then
- ?????
- else
- ?????
- end if
- else
- if ???c then
- ?????
- else
- ?????
- End if
- End if
???? ???
28Select case ????
- Select case ???
- case ????
- ?????
- case ????
- ?????
-
- Case else
- ????N
- End select
???? ???
29For next ??
- For ??????? to ??? step ???
- ????
- next
- For i1 to 10 step 1
- for j1 to 10 step 1
- ????
- next
- next
???? ???
30Do loop??
- 1?do while ??
-
- loop
- 2?do until ??
-
- loop
- 3?do
-
- loop while ??
- 4?do
-
- loop until ??
- 5?do
-
- if ?? then
-
- exit do
- end if
-
- loop
???? ???
31??????
- ??????
- Sub name(??1,,??n)
-
- End sub
- ?????
- Call name(??1,,??n)
- ?????????????
- ????????
- ???,??????????
- ?????
- Function name(??1,,??n)
-
- name???
-
- End function
- ?????
- Name(????1,,????n)
- Vbscript?????
- ????
???? ???
32??asp?????
- Asp???????
- ???????Request??
- Response??
- Cookies???
- ????
???
33Asp???????
- ????,????????????,???????????,????????????????????
?????????????(???),???????????????,????????????? - Asp????????
34Asp????????
?? ??
Request ????????
Response ???????????
Session ?????????
Application ??????????????????????
Server ??com???scripting???
352????????Request??
- Request??????????5???
- 1?form,??????form????????(????)
- 2?querystring,????????????????
- 3?cookies,?????????cookies??
- 4?servervariables,????????????
- 5?clientcertificate,???????????????
???? ???
36?????
- ???????
- ltform action?????????? methodpostget
name????gt - ??????
- lt/formgt
- ????????,???????
- 1????? 2????? 3?????? 4?????
- 5???? 6???? 7?????
- ???????????
- ???????
- post ???????????,??????? request(???)
- get ???????????,??????? request.querystring(
???)
???? ???
373?Response??
- Response.write ??????
- ???lt???/??gt,??????
- Response.redirect a.htm ?????
- ?lthtmlgt?????
- Response.end ?????????
- Resposne.buffertrue/false ???????????
- ?lthtmlgt?????
???? ???
384?Cookies
- Cookies?????????,?????WEB???????????????IE????,???
????????COOKIES,??IE???,??COOKIES????,????????????
????IE???????COOKIES? - ????????????cookies?,????????,????????COOKIES?
?? - COOKIES????????
- ?? response.cookies(name)values
- ?? ??request.cookies(name)
- ????cookies?,???????
- ??????
???? ???
395?????
- ?ASP?????????????????????,??scripting.filesy
stemobject???? - Filesystemobject????
- ???????????????????????????????????????
- Set ???server.createobject(scripting.filesystemo
bject) - ???????????
- 1??????
- Set ???filesystemobject??.createtextfile(
??????,????,????) - ???????false ???????true?unicode,false?ascII
??? - 2??????
- filesystemobject??.deletefile( ??????,??????)
- ?????????false????
405?????
- ????????
- filesystemobject??.fileexists( ??????)
- ????????true,????false
- ??????????
- ???????????????????,?????server???mappath??,?
?web???????????????????? - server.mappath(??????)
- ?????
- ??????????????????
- Set ???? filesystemobject??.opentextfile(
??????,??/????,?????) - ??/????1,??(??)?2,??,???????,????8,???
????? - ?????????false,???????????,?????
415?????
- ????????
- 1????????
- ??????.atendofstream
- ????true??????
- 2???????
- ??????.read(n)
- N???,???????N???
- 3?????
- ??????.readline
- 4?????????
- ??????.readall
425?????
- 5???????
- ??????.skip(???????)
- ??????.skipline ????
- ???????
- ??????.write(?????)
- ??????.writeline(?????)?write????????????????
-
43????????
- ??????ADO??
- SQL?????
- ??Recordset??????
???
441???????ADO??
- Asp??????
- ????????
- ????????
???? ???
45Asp??????
- ASP??????????
- access?mysql?sqlserver?oracle?
- Ado??
- ????PWS/IIS?,??????????ADO??(ACTIVEX DATA
OBJECT)??ASP????????????????????????ADO???????,???
?sql???recordset ????ADO?????????/??/??/????
???? ???
46??????
- ??????
- ????ACCESS??????liuyanban,??liuyan?,???
- name?????????
- neirong ????????
- shijian??????????
- ?????
???? ???
47??????????
- ????ACCESS??????
- set cnndbsever.createobject(adodb.connection
) - ???????????,????cnndb??????
- ??????????,????OPEN???????
- cnndb.open ?????,?????,??
- 1?????????,????????
- Providermicrosoft.jet.oledb.4.0data
source server.mappath(./liuyanban.mdb) - 2?????DSN
- ????DSNcnndb.open liuyanban
- 3?????DSN
- ????DSNcnndb.open filedsnserver.mappa
th(./liuyanban.mdb) - 4???DSN???DSN???
- 98?? ????odbc?????/??DSNmicrosoft
access drivers??
???? ???
48?????????
- Recordset?????
- Recordset???????????????????????,????
?????????????????????,????????????????,???????????
??recordset???movefirst(?????)?moveprevious(?????)
?movenext(?????)?movelast(??????)?????,???????????
?? - recordset???????
- set ????server.createobject(adodb.recor
dset) - recordset?????,??open??,???????????????????
- recordset????.open ???,????,????,????,??
- ????
- ????????? ????????connection????
- ??????recordset???????????????????
- 0????,?????????????????????,???????,??????
???? ???
49????
- 1,???????????????????????????,???????????,????????
?????????? - 2,????????????????????????????
- 3,????????????????????????????
- ????
- 1,??,??????????????????
- 2,????,?????????,?????
- 3,????,??????update???,?????
- 4,???????,?????????
- ??
- -1,?????????????????????????
- 1,?????????????????????
- 2,????????????????????
- 3,????????????????????
???? ???
50?????????
- ?set cnndbserver.createobject(adodb.connection
) - cnndb.open liuyanban
- set rstobjserver.createobject(adodb.reco
rdset) - rstobj.open liuyan,cnndb
- rstobj(name) ?????????
- do while not rstobj.eof ????????????
-
- rstobj.movenext
- loop
- rstobj.movelast?????????????
- do while not rstobj.bof ????????????
-
- rstobj.moveprevious
- loop
???? ???
51Recordset ????????
- ????recordset???,??????,??????????,????
- recordset????.close
- ????
- set recordset????nothing
???? ???
52????????
- ???????????
- Recordset????.fields.count ??rstobj.fields.count
- ?????????????
- Recordset????.fields(?????).name
??rstobj.fields(2).name - ???????
- ??Recordset????.recordcount
- ?????????
- ??Recordset????.absoluteposition
- ????????N???
- Recordset????.absolutepositionN
- ?????recordcount ?absoluteposition??,recordset???
open????????????1?3?
???? ???
532? SQL?????
- Sql????????????????????????????ASP???ADO??????Sql?
??????,????????????????? - ??ADO???recordset??????????,?????????,????????
?sql??,??recordset????????,???????????
???? ???
54Sql???????
- connection????.execute(????)
- ??set cnndbserver.createobject(adodb.connection
) - cnndb.open liuyanban
- strselect from liuyan ????SQL??
- cnndb.execute(str) ??SQL??
- ??recordset???open????select??
- set cnndbserver.createobject(adodb.connection
) - cnndb.open liuyanban
- strselect from liuyan ????SQL??
- rstobj.open str,cnndb
???? ???
55???????
- Connection????.execute(????)
- ??????
- Insert?update?delete??
???? ???
56?????select??
- ???
- Select ??1 as ????1,??2 as ????2, from
???? whereorder by - ?????????,where??????????,order by????
- Where??????????
- Like??????????
- ?????????,_?????????,?????????
???? ???
57?????select??
- ??????
- gt,lt,gt,lt,ltgt,,betweenand
- ??????
- gt,lt,gt,lt,ltgt,,betweenand
- Not??? where not ???
- In??? where ?? in(?1,?2,)???????
- ??????
- And ,or
- Order by ?? asc(??)/desc(??)
???? ???
58????
- Insert into ?(??1,??2) values(?1,?2)
- ???????????????????????
- values(request(name),)
???? ???
59???????
- Delete from ?? where ??
- Update ?? set ????? where ??
- ?????????????????
???? ???
603???Recordset??????
- ??recordset????????sql?????????????,?????,????????
??????????,?????????????,??????????????? - ??sql????????????????,?????????????,?recordset???u
pdate???????????????? - recordset??.update
- ??rstobj.open select from liuyan where
namedd,cnndb,1,2?????? - rstobj(name)request(name)????
- rstobj(neirong)request(neirong )
- rstobj(shijian)request(shijian)
- rstobj.update ????
???? ???
61Asp?????
- ?ASP???????????????????????????,??????????????????
??????,????ASP?????????,?????