1. Date and time

<html>
<body>

Today's date is: <%response.write(date())%>.
<br>
The server's local time is: <%response.write(time())%>.

</body>
</html>

 

2. Get the name of a day

<html>
<body>

<p>
VBScripts' function <b>WeekdayName</b> is used to get a weekday:
</p>
<%
response.Write(WeekDayName(1))
response.Write("<br>")
response.Write(WeekDayName(2))
%>

<p>Abbreviated name of a weekday:</p>
<%
response.Write(WeekDayName(1,true))
response.Write("<br>")
response.Write(WeekDayName(2,true))
%>

<p>Current weekday:</p>
<%
response.Write(WeekdayName(weekday(date)))
response.Write("<br>")
response.Write(WeekdayName(weekday(date), true))
%>

</body>
</html>

 

3. Get the name of a month 

<html>
<body>

<p>VBScripts' function <b>MonthName</b> is used to get a month:</p>
<%
response.Write(MonthName(1))
response.Write("<br>")
response.Write(MonthName(2))
%>

<p>Abbreviated name of a month:</p>
<%
response.Write(MonthName(1,true))
response.Write("<br>")
response.Write(MonthName(2,true))
%>

<p>Current month:</p>
<%
response.Write(MonthName(month(date)))
response.Write("<br>")
response.Write(MonthName(month(date), true))
%>

</body>
</html>

 

4. Get todays' day and month

<html>
<body>

Today it is
<%response.write(WeekdayName(weekday(date)))%>,
<br>
and the month is
<%response.write(MonthName(month(date)))%>

</body>
</html>

 

5. Countdown to year 3000

<html>
<body>

<p>Countdown to year 3000:</p>

<p>
<%millennium=cdate("1/1/3000 00:00:00")%>

It is
<%response.write(DateDiff("yyyy", Now(), millennium))%>
years to year 3000!
<br>
It is
<%response.write(DateDiff("m", Now(), millennium))%>
months to year 3000!
<br>
It is
<%response.write(DateDiff("ww", Now(), millennium))%>
weeks to year 3000!
<br>
It is
<%response.write(DateDiff("d", Now(), millennium))%>
days to year 3000!
<br>
It is
<%response.write(DateDiff("h", Now(), millennium))%>
hours to year 3000!
<br>
It is
<%response.write(DateDiff("n", Now(), millennium))%>
minutes to year 3000!
<br>
It is
<%response.write(DateDiff("s", Now(), millennium))%>
seconds to year 3000!
</p>

</body>
</html>

 

6. Calculate the day which is n days from today

<html>
<body>

<%
response.write(DateAdd("d",30,Date()))
%>

<p>
This example uses <b>DateAdd</b> to calculate a date 30 days from today.
</p>
<p>
Syntax for DateAdd: DateAdd(interval,number,date).
</p>

<%
response.write(DateAdd("d",10,Date()))
%>

<p>
This example uses <b>DateAdd</b> to calculate a date 10 days from today.
</p>
<p>
Syntax for DateAdd: DateAdd(interval,number,date).
</p>

</body>
</html>

 

7. Format date and time

<html>
<body>

<%
response.write(FormatDateTime(date(),vbgeneraldate))
response.write("<br>")
response.write(FormatDateTime(date(),vblongdate))
response.write("<br>")
response.write(FormatDateTime(date(),vbshortdate))
response.write("<br>")
response.write(FormatDateTime(now(),vblongtime))
response.write("<br>")
response.write(FormatDateTime(now(),vbshorttime))
%>

<p>
Syntax for FormatDateTime: FormatDateTime(date,namedformat).
</p>

</body>
</html>

 

8. Is this a date?

<html>
<body>

<%
somedate="10/40/11"
response.write(IsDate(somedate))
response.write("<br>")
somedate="18/30/99"
response.write(IsDate(somedate))
response.write("<br>")
somedate="10/30/99"
response.write(IsDate(somedate))
%>

</body>
</html>

 

[출처] www.w3schools.com/asp/asp_examples.asp

ASP에서 레코드셋을 이용하여 레코드를 이동하는 방법

 

DB 오픈할 때 커서 타입을 지정해 줘야 한다.

 ex) Rs.Open SQL, DB, 1 (MoveNext와 MoveFirst만 사용시에는 1없어도 됨)

다음 레코드로 이동 rs.MoveNext
이전 레코드로 이동 rs.MovePrevious
처음 레코드로 이동 rs.MoveFirst
마지막 레코드로 이돌 rs.MoveLast
총 레코드 갯수 구하기 rs.RecordCount

 

[출처] sunkyun.com/community/bbs/?t=N

배열 변수 Rs.GetRows()

배열은 2차원 배열로 만들어 지며 1차원 값은 원하는 컬럼 값이고 2차원은 컬럼에 해당하는 값이 들어간다.

 

Column 크기 : UBound (배열 변수, 1)

Row 크기 : UBound (배열 변수, 2)

* 배열은 0부터 시작하기 때문에 1 차이가 남


 

sql = "select * from emp"
oraRec.Open sql, oraConn, 1

a_arr   = oraRec.getrows
a_column = ubound(a_arr, 1)
a_row = ubound(a_arr, 2)

response.Write "a_column = " & a_column & "<br/>"
response.Write "a_row = " & a_row & "<br/>"

 

[출처] blog.naver.com/mavis5/10081206806

 

BOF는 Begin Of File로 레코드 셋의 시작, EOF는 End Of File로 레코드 셋의 끝을 의미한다.

레코드가 하나가 아닌 경우 가상 테이블의 형태로 레코드셋이 저장되고 그 시작과 끝을 구분해주는 것이 BOF와 EOF이다.

 

주로 DB에서 데이터를 불러오는 경우 사용

If Rs.EOF Or Rs.BOF Then
...(중략)
End If

 

DB에 데이터가 있는 경우 Rf.EOF와 RS.BOF는 false가 되고 데이터가 없는 경우 true가 된다.

일반적으로 아래처럼 EOF만 사용해서 데이터를 출력하는 데 많이 사용하고 있다.

If Not Rs.EOF Then
...(출력 데이터)
End If

if rs.BOF or rs.EOF then
  response.write "데이터가 존재하지 않습니다"
else
  response.write "데이터 출력"
end if

[출처] travelpark.tistory.com/51

페이지 단위로 인코딩을 설정하는 방법

이 경우 아래와 같이 코드를 페이지 최상단에 추가한다.

<%@Language="VBScript" CODEPAGE="65001" %>
<%
 
  Response.CharSet="utf-8"
  Session.codepage="65001"
  Response.codepage="65001"
  Response.ContentType="text/html;charset=utf-8"
%>

 

[출처] codelib.tistory.com/28

'프로그램 > ASP' 카테고리의 다른 글

[ASP] If문, For문, Do While문  (0) 2021.03.09
[ASP] BOF와 EOF의 의미  (0) 2021.03.09
[ASP] 기초 문법 실습하기  (0) 2021.03.03
ASP 기본 문법 I  (0) 2021.03.03
ASP 란 무엇인가?  (0) 2021.03.03

 

1. 서버와 클라이언트7
한 컴퓨터에서 다른 컴퓨터로 어떤 문서 및 정보를 보여달라고 요구했을 때 그 자료를 요청한 컴퓨터를 '클라이언트', 제공해 주는 컴퓨터를 '서버'라고 한다.
서버(Server)는 '제공자, 제공하는 것'이여,
클라이언트(Client)는 '의뢰인, 고객'을 의미한다.

2. 웹서버 (Web Server)
웹 서버란 '웹 서비스를 제공하는 서버'라고 한다.
서버는 서버인데, 웹(www) 상에 있는 서버이기 때문에 인터넷만 연결되어 있다면 어느 나라 어느 장소에 있는 사람이라도 그 곳을 방문 할 수 있다.

3. IIS (Internet Information Services)
IIS란 ASP 페이지가 실행될 수 있는 환경을 제공하는 '웹 서버 프로그램'의 이름이다.

웹 서버의 의미를 '하드웨어(컴퓨터 본체)' 라고 한다면,
IIS란 '소프트웨어(프로그램)'을 의미한다고 생각하면 된다. 

 

ASP란 무엇인가?

ASP란 'Active Server Pages'의 약자이며, '동적으로 서버에서 작동하는 페이지'로 해석한다.

 

<HTML>
<HEAD>
<TITLE> Welcome To Dukyoung.net </TITLE>
</HEAD>
<BODY>
<CENTER>
<% IF Hour(Now) < 12 THEN %>
지금은 오전입니다.
<% ELSE %>
지금은 오후입니다.
<% END IF%>
</CENTER>
</BODY>
</HTML>

 

<% IF Hour(Now) < 12 THEN %>

1. Now() 함수

컴퓨터 시스템에서의 '현재 시간'을 표시

 

2. Hour() 함수

24시간으로 환산한 '시간'을 나타내는 인자가 들어감. 

 

3. IF ~ THEN (조건문)

'만약 ~ 이라면' 이라는 뜻을 가짐. IF와 THEN 사이에는 '참' 또는 '거짓'을 판별할 수 있는 조건이 들어감.

IF 조건 THEN
참일 때의 처리 실행
ELSE
거짓일 때의 처리 실행
END IF

 

1. ASP는 '<%' 으로 시작하여 '%>'으로 끝난다.
2. 클라이언트들은 오직 ASP 코드가 실행된 후의 HTML 페이지만을 볼 수 있다.

 

출처  taeyo.net/lecture/Dukyoung/DYsASP05.asp

'프로그램 > ASP' 카테고리의 다른 글

[ASP] BOF와 EOF의 의미  (0) 2021.03.09
[ASP] 한글 깨짐 해결 방법  (0) 2021.03.08
[ASP] 기초 문법 실습하기  (0) 2021.03.03
ASP 기본 문법 I  (0) 2021.03.03
ASP와 ASP.NET의 차이점  (0) 2021.03.03

 

 

  ASP ASP.NET
컴파일 유/무 인터프리터 방식 컴파일러 방식
플랫폼 측면 IIS 상에서 운영 IIS 와 .NetFramework상에서 운영
소스를 구성하는 기반 언어 VBScript, JScript 닷넷 언어 (C#, VB...)

 

 

참고 링크 www.taeyo.net/Forum/Content.aspx?TBL=ASPNET&SEQ=31335

'프로그램 > ASP' 카테고리의 다른 글

[ASP] BOF와 EOF의 의미  (0) 2021.03.09
[ASP] 한글 깨짐 해결 방법  (0) 2021.03.08
[ASP] 기초 문법 실습하기  (0) 2021.03.03
ASP 기본 문법 I  (0) 2021.03.03
ASP 란 무엇인가?  (0) 2021.03.03

+ Recent posts