- ASP 프로그램
- 상수와 변수
- Application
- Session
- Server
- ASP 프로그램 입출력
- 브라우저 입출력
- File 입출력
- D/B 입출력
- ADO 기본 문법
- Scripting
- Active Server Component
- 용어 정의
- 참고 문헌
프로그램 언어인 ASP를 정리한다.
ASP 프로그램
상수와 변수
상수 정의 파일
c:/Program Files/Common Files/System/ado/adovbs.inc : VBScript에서 사용하는 상수
c:/Program Files/Common Files/System/ado/adojavas.inc : JavaScript에서 사용하는 상수
변수 타입
Data Type Prefix 변환 함수
Boolean bln Cbool()
Byte byt Cbyte()
Currency cur Ccur()
Date-time dtm Cdate(), #20/10/2003#
Double dbl CDble()
Error err CVErr()
Integer int Cint()
Long lng CLng()
Single sng CSng()
String str CStr()
Variant vnt CVar()
Object obj
Collection object col
User-defined type udt
Empty
Null
ADO command cmd
ADO connection cnn
ADO field fld
ADO parameter prm
ADO recordset rst
===ASP 문법===
With AAA
.~ = ~
End With
Function theFunc()
theFunc = ~
End Function
~.onClick = GetRef("theFunc")
8Public Sub ~ (~)
End Sub
- Sub Application_onStart() / onEnd()
- Sub Session_onStart() / onEnd()
Class theClass
private
End Class
set ~ = new theClass
<Object ID="~" RUNAT="SERVER/CLIENT" SCOPE="APPLICATION/SESSION"
codebase="~" PROGID="~" / CLASSID="~"
문자열 실행
- ~ = Eval(~)
- Execute(~), vbCrLf
Application
Session
Session.Contents.Remove("~")
Session.Contents.RemoveAll()
Session.Abadnon()
Server
Server.CreateObject("~")
Server.Execute("~")
Server.Transfer("~")
Server.HTMLEncode("~")
Server.URLEncode("~")
ASP 프로그램 입출력
브라우저 입출력
Request
Requset.Cookies
Response
Response.Charset = "EUC-KR"
Response.ContentType = "text/html"
Response.write("~")
Response.Flush()
Response.End()
Response.Redirect("~")
Response.Cookies
File 입출력
Set file = Server.CreateObject("Scripting.FileSystemObject")
D/B 입출력
Database Open
Dim conn As New ADODB.Connection
'Set conn = Server.CreateObject("ADODB.Connection")
conn.Open("DSN=~; UID=~; pwd=~;")
conn.Open("PROVIDER=SQLOLEDB; SERVER=~; DATABASE=~; UID=~; pwd=~;")
conn.close
set conn = Nothing
DB 1 record Select
Dim rs1 As New ADODB.Recordset
sql = "select *" & _
" from domestic_tour_info" & _
" where price_id = '" & price_id & "'"
set rs1 = conn.execute(sql)
'rs1.Open sql conn
Set Flds = rs1.Fields
if (Not rs1.EOF) then
For Each fld in Flds
Debug.print fld.Value
fld.Name, fld.Type
Next
price_id = [rs1("price_id") %>](<%=)
endif
rs1.close
Dim TotalCount As Integer
TotalCount = Flds.Count
DB multi record Select
Dim rs As New ADODB.Recordset
'Set Rs = Server.CreateObject("ADODB.Recordset")
sql = "select *" & _
" from fee_info " & _
" where price_id = '" & price_id & "'" & _
" order by fee_seq"
Rs.Open Sql, Conn, 1, 1
'Rs.MoveFirst
While Not Rs.EOF
fee_id = [rs("fee_id") %>](<%=)
Rs.MoveNext
Wend
Rs.close
set Rs = Nothing
DB insert/update
sql = "update domestic_tour_info" & _
" set save_location = 'rail' " & _
" where price_id = 'HDR0403002'"
conn.execute(sql)
Transaction
cn.BeginTrans
cn.CommitTrans
cn.RollbackTrans
Error handling
Dim errLoop As ADODB.Error
For Each errLoop In cn.Errors
Dim strError(5)
Dim i As Integer
strError(0) = "Error Number: " & errLoop.Number
strError(1) = " Description: " & errLoop.Description
strError(2) = " Source: " & errLoop.Source
strError(3) = " SQL State: " & errLoop.SQLState
strError(4) = " Native Error: " & errLoop.NativeError
Next
i f (err.number = 0) Then
response.write err.description
end if
ADO 기본 문법
SQL에서 날자변환 함수
substring(convert(varchar, tour_start_term, 112), 1, 6)
ADODB.Connection
Dim objConn, strConn
Dim objRS, strSql, lngRows
Set objConn = Server.CreateObject("ADODB.Connection")
~.dsn 참조
strConn = "Provider=SQLOLE DB;Data Source=MyServer;Initial Catalog=winip;User Id=~;Password=~"
strConn = "Provider=Microsoft.Jet.OLE DB.4.0;Data Source=c:/~/~.mdb"
strConn = "DSN=hongiktour;UID=~;PWD=~"
strConn = "Provider=MSDAIPP.DSO;Data Source=http://~/;User ID=~;Password=~"
strConn = "Provider=MSDAOORA.1;Password=~;User ID=~;Data Source=~"
if (objConn.state = adStateClosed) then
objConn.Open strConn
end if
On Error Resume Next
Set objRS = objConn.Execute(strSql, lngRows, adCmdText)
if (Err.Number <> 0) then
For intCount = 0 to objConn.Errors.Count - 1
objConn.Errors.Item(intCount).Description
Next
end if
if (objConn.Properties("Transaction DDL") <> DBPROPVAL_TC_NONE) then
objConn.BeginTrans
objConn.CommitTrans
objConn.RollbackTrans
end if
if (objConn.state = adStateOpen) then
objconn.close
end if
Set objConn = Nothing
ADODB.Command
Dim objCmd
Dim objRS, strSql, lngRows
Set objCmd = Server.CreateObject("ADODB.Command")
Set objCmd.ActiveConnection = objConn, strConn
obCmd = adStateColsed, adStateOpen
objCmd.CommandText = strSql
objCmd.CommandType = adCmdText, adCmdStoredProc, adCmdFile
objCmd.Parameters("@~").Value = ~
arrParams = Array("~", "~", "~")
objCmd.Prepared = true
Set objRS = objCmd.Execute(lngRows, arrParams, adExecuteNoRecords or adCmdText)
Set objCmd.ActiveConnection = Nothing
ADODB.Parameter
lngCount = objCmd.Parameters.Count
objParam = objCmd.Parameters(index|name)
Set objParam = objCmd.CreateParameter("@~", adInteger, adParamInput)
Name, Type, Direction, Size, Value
- Type : adBoolena, adCurrency, adDBTimeStamp, adDecimal, adInteger, adNumeric,
adSingle, adSmallInt, adUnsignedTinyInt, adVarBinary, adVarChar
- Direction : adParamInput, adParamOutput, adParamInputOutput, adParamReturnValue
objCmd.Parameters.Append objParam
objCmd.Parameters.Delete index|name
objCmd.Parameters("RETURN_VALUE").Value
ADODB.Recordset
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.open source, ActiveConnection, CursorType, LockType, Options
CursorType : adOpenForwardOnly, adOpenKeySet (1), adOpenDynamic, adOpenStatic
LockType : adLockReadOnly, adLockPessimistic, adLockOptimistic, adLockBatchOptimistic
objRS.Fields.Item("~").Value = ~, Fields.Count
Fields : Name, Value, UnderlyingValue, OriginalValue, Type
objRS.Update
objRS.Update Array(~), Array(~)
objRS.AddNew --> objRS.Update
objRS.AddNew Array(~), Array(~)
objRS.Delete
objRS.Supports(adMovePrevious) = true, false
objRS.Move int
objRS.MoveFirst, MoveLast, MoveNext, MovePrevious, EOF, BOF, RecordCount
.c : 캐비넷파일(.cab) 압축 툴~.vbp : 패키지 및 배포 마법사
MSPRPXO.DLL
MSSTKPRP.DLL
VB6 런타임 및 OLE 자동화
VB6ko.DLL
MS에서 제공하는 테스트툴로 인증 및 배포 : codesizg.exe
makecert -sv memo.pvk memo.cer
cert2spc memo.cer memo.spc
signcode -spc memo.spc -v memo.pvk -n "memo" ~.cab
chktrust ~.cab
codebase=http://~/~.CAB
IIS Admin
http://server:adminPort/iis.asp
mmc /a
regsvr32 ~.dll /u
로드 밸런싱
DNS 라운드 로빈
L4
TCP/IP 네트워크 로드밸런싱 (NLB)
High Availability Clustering
COM+ Dynamic Load Balancing
Scripting
Directory
- Server.CreateObject("Scripting.Directionary")
- Add(key, item), Exist(key), Items(), Keys(), Remote(key), RemoveAll(), Count, Item(key), Key(key)
FileSystemObject, Drivers, Folders, Files, TextStream
Active Server Component
용어 정의
ADO (ActiveX Data Objects)
RDS (Remote Data Service)
UDA (Universal Data Access)
CDO (Collaboration Data Object)
MTS (Microsoft Transaction Server)
참고 문헌
분류: 프로그램_언어