달력

52024  이전 다음

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
반응형
참고 : http://blog.naver.com/pickymarco/164248663

 

 

if isEmpty(AA) = False And isNumeric(AA) = True then

~~~

else

~~~

end if

반응형
Posted by 친절한 웬디양~ㅎㅎ
|
반응형


OpenTextFile method는 명시된 파일을 열고 파일에 접근하기 위해 사용되어지는 TextStream object를 반환한다.


Syntax


FileSystemObject.OpenTextFile(fname,mode,create,format) 

 


Parameter

Description

fname

Required. 파일의 이름

mode

선택사항. 파일을 여는 방법
1=ForReading –
읽기로 파일을 연다. 파일에 없다.
2=ForWriting –
쓰기로 파일을 연다.

8=ForAppending – 파일을 열고 파일의 마지막에 쓴다

create

선택사항. 파일이름이 존재하지 않을 경우 새로운 파일을 생성할 지를 설정한다. True 새로운 파일이 생성될 있다는 것을 나타내고, False 새로운 파일이 생성될 없다는 것을 나타낸다. False default이다.

format

선택사항. 파일의 양식
0=TristateFalse – ASCII
파일을 연다. 이것은 default.이다
-1=TristateTrue – Unicode
파일을 연다.
-2=TristateUseDefault - system default
사용하여 파일을 연다.

 


Examples


<%

dim fs,f

set fs=Server.CreateObject("Scripting.FileSystemObject")

set f=fs.OpenTextFile(Server.MapPath("testread.txt"),8,true)

f.WriteLine("This text will be added to the end of file")

f.Close

set f=Nothing

set fs=Nothing

%> 

 


원본 사이트 : http://www.w3schools.com/asp/met_opentextfile.asp


반응형
Posted by 친절한 웬디양~ㅎㅎ
|
반응형

출처 : http://ngio.co.kr/3038

asp - JSON  : http://www.aspjson.com/

 

ASPJSON is a free to use project for generating and reading JSON data into a classic ASP object.

The class can be used for reading a string of JSON data as well as writing JSON output from an AJAX file.
Below are 2 simple examples of both.

 

<!--#include virtual="/aspJSON1.17.asp" -->
<%
Set oJSON = New aspJSON

'Load JSON string
oJSON.loadJSON(jsonstring)

'Get single value
Response.Write oJSON.data("firstName") & "<br>"

'Loop through collection
For Each phonenr In oJSON.data("phoneNumber")
    Set this = oJSON.data("phoneNumber").item(phonenr)
    Response.Write _
    this.item("type") & ": " & _
    this.item("number") & "<br>"
Next

'Update/Add value
oJSON.data("firstName") = "James"

'Return json string
Response.Write oJSON.JSONoutput()
%>

 

 

[INPUT]
{ "firstName": "John", "lastName" : "Smith", "age" : 25, "address" : { "streetAddress": "21 2nd Street", "city" : "New York", "state" : "NY", "postalCode" : "10021" }, "phoneNumber": [ { "type" : "home", "number": "212 555-1234" }, { "type" : "fax", "number": "646 555-4567" } ] }

 

 

 

반응형
Posted by 친절한 웬디양~ㅎㅎ
|
반응형
/asp getRows 와 nextrecordset

 

※ getrows를 하게 되면 레코드의 커서는 eof 가 된다. 다시 처음 위치로 놓을려면 rs.MoveFirst 해주어야 한다.

 

1. getRows 메소드

  recordSet의 결과를 열,행 의 2차원 배열로 반환한다.

 배열이 생기면 레코드셋은 사용하지 않으므로 nothing~

 

2. nextrecordset 메소드

  쿼리문이 ";" 로 주욱. 연결되어있을때, 그 다음 레코드 셋을 가져오도록 하는 메소드.

  다음 쿼리문만 가져올 수 있고, 한 번 수행된 이전 쿼리문은 접근 불가.

 

 

첫번째 질문은 테이블의 컬럼 명을 확인하고 싶은 신 건가요?

 

그럼 쿼리 분석기에서 다음과 같이 입력하고 실행해 보시면 되실 겁니다.

 

Select * From syscolumns
Where id = (Select id From sysobjects Where xtype = 'U' And name = '테이블명')

 

그리고 컬럼의 단위로 하시고 싶으시다면

그것은 레코드셋 보다는 배열을 이용하시는 것이 더 편하실 겁니다.

레코드셋을 배열로 해 주는 명령은

 

 

 

배열변수 = Rs.GetRows()

위와 같이 배열로 받아서 처리 하시면 됩니다.

 

배열은 2차원 배열로 만들어 지며

1차원값은 원하시는 컬럼 값이고 2차원은 컬럼의 해당하는 값이 들어 갑니다.

즉,

Column 크기는 UBound(배열변수, 1)를 하시면 크기가 나오고

Row 크기는 UBound(배열변수, 2)를 하시면 됩니다.

 

참고로 배열은 0부터 시작하기 때문에 갯수로 크기보다 1이 더 큽니다.

즉,

배열의 크기가 3이라하면

배열변수(0), 배열변수(1), 배열변수(2), 배열변수(3) 까지 총 4개의 배열이 존재하는 거죠

 

ex1)

dim rs : set rs = conn.execute("select * from bbs") '

dim getrowRs : getrowRs = rs.getRows()

response.write ubound(getrowRs, 1) '열 (컬럼)
response.write ubound(getrowRs, 2) '행 (레코드)

 

ex2)

set objrs = server.createobject("adodb.recordset")
objrs.open "select * from bbs", conndb, adopenstatic

dim getrowRs : getrowRs = objrs.getRows()

response.write ubound(getrowRs, 1) '열 (컬럼)
response.write ubound(getrowRs, 2) '행 (레코드)

 

 

[nextrecordset]

 

<%
   ' 쿼리문에 여러 개의 레코드셋을 가져오는 경우도 있으므로
   ' 다음과 같이 모든 레코드를 가져올 수 있도록 처리한다.
   Do Until objRs is Nothing
    intCount = objRs.Fields.Count

    if ( intCount <> 0 ) then
     Response.Write "<TR bgcolor = #efefef height=22>"

     ' 컬럼의 이름을 출력하는 부분
     For intLoop = 0 to intCount - 1
      Response.Write "<TD><b>"
      Response.Write objRs.Fields( intLoop ).Name  ' 컬럼의 이름을 가져온다.
      Response.Write "</b></TD>"
     Next

     Response.Write "</TR>"

     ' 실제 레코드를 출력하는 부분
     Do Until ( objRs.EOF = True )
      Response.Write "<TR bgcolor=white>"

      For intLoop = 0 to intCount - 1
       Response.Write "<TD bgcolor=white>"
       Response.Write objRs( intLoop )
       Response.Write "</TD>"
      Next

      Response.Write "</TR>"
      objRs.MoveNext
     Loop
    end if

    Set objRs = objRs.NextRecordSet
   Loop
%>

http://blog.naver.com/mavis5/10081206806

반응형
Posted by 친절한 웬디양~ㅎㅎ
|

asp 날짜 함수들

Develope/ASP 2010. 8. 12. 11:47
반응형
now : 2006-07-25 오후 6:52:24
now + 1 : 2006-07-26 오후 6:52:24
date : 2006-07-25
dateadd : 1995-02-28
datediff : 4165
datepart : 3
dateserial : 1980-05-31
DateValue : 1963-09-11
time : 오후 6:52:24
Timeserial : 오전 5:45:00
timevalue : 오후 4:35:17
isdate(theday) : True
second : 24
second : 31
minute : 52
hour : 18
day : 25
weekday : 3
weekdayname : 화요일
month : 7
monthname : 7월
year : 2006

반응형
Posted by 친절한 웬디양~ㅎㅎ
|
반응형
출처 : http://maru7937.egloos.com/4840021

If abc("file") <> "" Then 
   FileCnt = abc("file").count
Else
   FileCnt = 0
End If

Dim i
Dim FileName(), FileName(), FileType()
Redim FileName(FileCnt), FileName(FileCnt), FileType(FileCnt)

For i = 1 To FileCnt    

Set oFile =  ABC(trim("file"))(i)

If oFile.FileExists Then

FileName(i) = oFile.SafeFileName
FileSize(i) = oFile.Length
FileType(i) = oFile.FileType

 If FileSize(i) > 500000 then
  Response.Write "<script language=javascript>"
  Response.Write "alert('500K 이상의 사이즈인 파일은 업로드하실 수 없습니다');"
  Response.Write "history.back();"
  Response.Write "</script>"
  Response.end
  
  Else if lcase(FileType(i)) <> "gif" and lcase(FileType(i)) <> "jpg" then
   Response.Write "<script language=javascript>"
   Response.Write "alert('확장자는 반드시 Jpg또는 Gif로 올려주세요');"
   Response.Write "history.back();"
   Response.Write "</script>"
   Response.end
  Else
 
   strFileWholePath = DirectoryPath&"\"&goods_code&"_"&I&"."&FileType(i)
 
   oFile.Save strFileWholePath
  
  End if
  
 End if
 
End if

Next

----------------------------------------------------------------------------------------------

화일명이 중복되있다면 파일명을 변경하는 함수입니다. 잘쓰세요..

strFileWholePath = GetUniqueName(FileName(i), DirectoryPath)

' 업로드시 중복화일 화일명 변경 처리 함수
Function GetUniqueName(byRef strFileName, DirectoryPath)
 Dim strName, strExt, strLen, strCom, strNow
 ' "."확장자가 있는지 확인한다
 If Instr(strFileName, ".") Then
  strNow = "Y"
 Else
  strNow = "N"
 End If

 Dim fso : Set fso = Server.CreateObject("Scripting.FileSystemObject")
  
 Dim bExist : bExist = True 
 '우선 같은이름의 파일이 존재한다고 가정
 Dim strFileWholePath
 '저장할 파일의 완전한 이름(완전한 물리적인 경로) 구성
 Dim countFileName : countFileName = 0 
 '파일이 존재할 경우, 이름 뒤에 붙일 숫자를 세팅함.
  
 If strNow = "Y" Then  '확장자가 있을때
  ' 확장자를 제외한 파일명을 얻는다.
  strName = Mid(strFileName, 1, InstrRev(strFileName, ".") - 1)
 Else
  strName = strFileName
 End If

 strExt = Mid(strFileName, InstrRev(strFileName, ".") + 1)
 '확장자를 얻는다
 strFileWholePath = DirectoryPath & "\" & strFileName

 Do While bExist ' 우선 있다고 생각함.
  If (fso.FileExists(strFileWholePath)) Then ' 같은 이름의 파일이 있을 때
   countFileName = countFileName + 1 '파일명에 숫자를 붙인 새로운 파일 이
름 생성
   strFileName = strName & "(" & countFileName & ")." & strExt
   If strNow = "Y" Then
    strFileName = strName & "(" & countFileName & ")." & strExt
   Else
    strFileName = strName & "(" & countFileName & ")"
   End If
   strFileWholePath = DirectoryPath & "\" & strFileName
  Else
   bExist = False
  End If
 Loop
 GetUniqueName = strFileWholePath
End Function

반응형
Posted by 친절한 웬디양~ㅎㅎ
|

asp 문법

Develope/ASP 2010. 8. 12. 11:46
반응형
 

출처 : http://maru7937.egloos.com/4840019

 선언한 크기 까지만 가능하다. 
   만약 그 이상의 값을 할당하면 에러가 발생한다.
   위에서는 2로 크기를 선언 했기 때문에 MyArray(2) 까지만 가능하다.


    ② Redim

  * 배열 크기의 재선언에 사용한다.

   예제 ②
     <%
      Dim MyArray_1()

      Redim MyArray_1(3)
          MyArray_1(0) = "대한민국"
          MyArray_1(1) = "터키"
          MyArray_1(2) = "세네갈"

      Redim MyArray_1(5) '배열의 크기를 재선언함(배열의 크기가 재선언 되면 기존

의 값들은 지워진다.)

      response.write MyArray_1(0) '값이 지워졌기 때문에 출력값이 없다..
     %>


     
  * redim 의 사용은 위처럼, 처음 배열 선언시에 배열의 크기를 정해 주지 않았을 때

에만 가능하다.
    예제 ① 에서 처럼 배열의 선언시에 크기를 선언한 경우에는 Redim 을 사용할 수

없다.


    ③ Preserve

 * 위의 예제 ②에서 
   Redim preserve Myarray_1(5) 처럼 preserve 가 쓰이면 데이터를 저장한 채로 배열

의 크기를 
             늘려준다.
   즉, 기존의 들어가 있는 데이터는 그대로 아직 존재한다. 
       따라서 대한민국이 출력된다.

 

    ④ 배열의 선언과 동시에 값 할당.

 예제 ④

 <%
 dim color
     color=Array("yellow","green","beige","silver")

 response.write color(0) '배열의 첫번째 값인 yellow 가 출력된다.
 %>


 
    ⑤ Option Explicit

 * 변수선언을 반드시 하도록 설정할 때 사용한다.


 예제 ⑤
 
 <%
   Option Explicit
   dim boy 
       boy = "소년"
       girl = "소녀"

   response.write boy & girl
 %>


 

 * 위에서 girl 은 변수에 값을 할당하기 전에 변수의 선언이 없으므로 에러가 발생한

다.
 * 주의 할 것은 Option Explicit 선언은 반드시 문서의 최 상단에 있어야 한다.
   문서의 중간에서 선언 될 수는 없다.

■ 구분자

   :

 * ASP에서 구분자로는  :(콜론) 이 쓰인다.
 * 구분자는 실행할 문장을 한줄단위로 구분짓는 역할을 한다.

 사용예)
 
 <%
   dim girl:
   dim boy : boy="소년" : response.write boy
 %>
 

 * 위에서 두번째 문장은 에러가 발생해야 하지만 구분자(:)가 있기 때문에 에러가 발

생하지 않는다.

■ 연결연산자

   &

 * &가 문자열에 쓰이면 문장과 문장을 연결해서 한 문장으로 만들어준다.
 * &가 변수에 쓰이면 변수의 값을 & 다음의 값과 이어준다.

 사용예)

 <%
    dim boy, girl, all
        boy = "김" & "영한"
        girl = "소녀"
        all = boy & girl
        all = all & "결과"

    response.write boy & "<br>"
    response.write all
 %>
 

 * 위에서 boy 의 값은 "김영한" 이며
   all 의 값은 "김영한소녀결과" 이다.


■ 주석

   '

 * ASP에서 주석처리에는 '(작은 따옴표) 가 쓰인다.
 * 행에서 ' 다음의 내용은 주석처리되어 해석이 되지 않는다.

 사용예)

 <%
   'dim boy
   'boy = "소년" 
   'response.write boy
 %>
 

 * 이렇게 하면 위의 문장들은 실행이 되지 않고 무시된다.

 

■ ASP 문자열 및 수학 함수

1. 문자열 및 수학 함수

 cint(문자열)  문자열을 정수값으로 출력(32768 이상의 큰 숫자에는 사용할 수 없다)

 사용예)

            <%=cint("100")+cint("100")%><br>
      <%="100" + "100"%>

     

     * 따옴표(") 가 붙었기 때문에 100 이 문자열이어서 100100 이어야 하지만
       첫번째 라인은 숫자형으로 변환을 했기 때문에 200 이 출력 된다.


 cdbl(문자열)  문자열을 소수점이하까지도 출력(큰 숫자에 사용한다)

 round(숫자,반올림할 위치)  지정한 소수점 자리에서 반올림한 값을 리턴

 asc(문자열)  문자열에서 첫번째 문자에 대한 ansi 코드 번호를 리턴

 chr(아스키코드번호)  지정된 번호와 일치하는 ansi 문자로 구성된 문자열을 리턴

 hex(숫자)  숫자의 16진수값을 나탸내는 문자열을 리턴

 fix(숫자)  숫자의 정수(전체)부분을 리턴 / 음수일때 숫자보다 크거나 같은 첫번째

음의 정수 리턴

 int(숫자)  숫자의 정수(전체)부분을 리턴 / 음수일때 숫자보다 작거나 같은 첫번째

음의 정수 리턴

 sgn(숫자)  숫자의 부호를 나타내는 정수를 리턴

 cdate(숫자)  날짜 형식의 인자값 리턴( 예:cdate(36890) , cdate("2001년 12월 10일

") )

 Clng(숫자)   Long 형식의 문자열 리턴

 Cstr(숫자)   String 형식의 문자열 리턴

 Csng(숫자)   Single 형식의 문자열 리턴

 formatcurrency(숫자) : 숫자를 화폐형식으로 전환
 formatdatetime(date,1) : date 함수의 표시형태를 바꿈
 formatdatetime(date,2)
 formatdatetime(date,3)
 formatpercent(숫자) : 숫자를 백분율로 표시

 strConv 지정한대로 문자를 변환.
  strConv(문자열,conversion [,LCID])
  
 >> conversion 에 가능한 값

 vbUpperCase 1 문자열을 대문자로 변환
 vbLowerCase 2 문자열을 소문자로 변환
 vbPropercase 3 문자열 단어의 첫글자를 대문자로 변환
 vbWide 4 1바이트문자를 2바이트 문자로 변환
 vbNarrow 5 2바이트문자를 1바이트문자로 변환
 vbUnicode 6 시스템의 기본 코드 페이지를 사용하여 문자열을 unicode

로 변환
 vbFromUnicode 128 unicode 문자열을 시스템의 기본 코드 페이지로 변환


3. 난수 함수(임의의 수를 리턴함)

 Randomize : 난수 발생기를 초기화 합니다.

 난수값 = Int((상한값 - 하한값) + 1) * Rnd + 하한값

 예로 1부터 100사이의 난수를 가져오려면,
 난수값 = Int(100 - 1 + 1) * Rnd + 1


4. 삼각 함수

 Atn() : 숫자의 아크 탄젠트 값을 리턴
 Cos() : 각도의 코사인값을 리턴
 Exp() : e(자연 로그의 밑)의 인자만큼의 제곱을 리턴
 Log() : 숫자의 자연로그를 리턴
 Sin() : 각도의 사인값을 리턴
 Tan() : 각도의 탄젠트값을 리턴

5. 문자열 관련 함수

 InStr("문자열","찾을 문자") 문자열의 위치 반환

     사용예)

     
     <%=instr("월드컵","대한민국 월드컵 코리아")%>

     * 실행결과 : 6
     * 만약 찾는 문자가 없다면 0 을 반환한다.
     * 문자열에서 시작은 1 부터 시작하며, 공백은 1 자리로 계산된다.

 InStrRev("문자열","찾을 문자") 문자열의 위치를 뒤에서 부터 검색해서 반환
 Lcase("문자열") 문자열을 소문자로...
 Ucase("문자열") 문자열을 대문자로...

 Len("문자열") :문자열의 길이 반환

 문자열 잘라내기

 Left("문자열",잘라낼 갯수) : 문자열을 왼쪽에서 지정한 갯수만큼 잘라냄
 Right("문자열",잘라낼 갯수) : 문자열을 오른쪽에서 지정한 갯수만큼 잘라냄

 문자열 뽑아내기
 Mid("문자열",시작위치,뽑아낼 갯수) : 문자열의 어느 부위를 뽑아냄

 문자열에서 공백문자 제거
 Yrim("문자열") : 문자열의 양쪽 공백을 제거
 Ltrim("문자열") : 문자열의 왼쪽 공백을 제거
 Rtrim("문자열") : 문자열의 오른쪽 공백을 제거

 Split("문자열","분리자") : 분리자를 기준으로 문자열을 나눔
 Splite()함수예제 : 
    str1 = Splite("사람,동물,인형",",")
    즉, "사람,동물,인형" 이라는 문자열을 "," 를 기준으로 잘라내면 자동 배열이 형

성되어 각각
    str1(0) = "사람"
    str1(1) = "동물" 
    str1(2) = "인형"  
    의 값을 가지게 된다.


 StrReverse("문자열") : 문자열을 뒤집음

 기타 확인함수

 IsArray() 변수가 배열인지의 여부를 나타내는 Boolean 값을 리턴
 IsDate() 날짜로 변환될 수 있는지의 여부를 나타내는 Boolean 값을 리턴
 IsEmpty() 변수가 초기화 될 수 있는지의 여부를 나타내는 Boolean 값을 리턴
 IsNull() 유효한 데이터를 포함하고 있는지의 여부를 리턴
 IsNumeric() 숫자로 평가될 수 있는지의 여부를 리턴
 IsObject() 유효한 ActiveX혹은 OLE 자동화 개체를 참조하는지의 여부를 리턴
 Vartype() 변수의 하위 형식을 나타내는 숫자를 리턴한다.

     사용예)

     <%
     Dim boy
         boy="소년"
     response.write IsNull(boy)
     %>

      * 실행결과: boy 변수는 NULL 이 아니므로 false 를 반환한다.


6. 날짜/시간 함수 예제

 ♠ now : 시스템의 시간과 날짜
 ♠ date : 시스템의 날짜
 ♠ time : 시스템의 시간

 현재의 년도 : year(now)
 현재의 월 month(now) , monthname(month(now))
 현재의 일 day(now)
 현재의 요일 : weekday(now) , weekdayname(weekday(now))
 현재의 시 : hour(now)
 현재의 분 : minute(now)
 현재의 초 : second(now)

  예)

  * 오늘의 날짜와 시간 : <%=now%>
  * 오늘의 날짜 : <%=date()%> 
  * 현재 시간 : <%=time%> 
  * 올해 : <%=year(now)%>
 ♠ DateAdd

 >> 지정된 날짜에 시간을 추가하거나 뺀 새로운 날짜를 반환한다.

 사용법 : DateAdd(interval, number, date)

 >> interval : 필수적인 인수로 interval을 추가한 날짜를 나타내는 문자식이다. 
 >> number : 필수적인 인수로 추가할 간격 수의 수식이다. 
             수식에서 양수는 미래의 날짜, 음수는 과거의 날짜이다. 
 >> date : 필수적인 인수로 interval을 추가한 날짜를 나타내는 Variant 또는 리터럴

이다.

 interval 에 가능한 값은 아래와 같다.

  yyyy 년 
  q 분기 
  m 월 
  y 일(일년 기준) 
  d 일 
  w 요일 
  ww 주(일년 기준) 
  h 시 
  n 분 
  s 초

  예)

  DateAdd("m",3,Date) >> 현재의 날짜에서 3개월을 더함
  DateAdd("m",-3,Date) >> 현재의 날짜에서 3개월을 뺌

 ♠ DateDiff

 >> 주어지는 두 날짜의 간격을 반환한다.

 사용법 : DateDiff(interval, date1, date2 [,firstdayofweek[, firstweekofyear]])

   >> interval : 필수적인 인수로 날짜1과 날짜2 사이의 차이를 계산하는 데 사용할

interval의 
       문자식이다. 
   >> date1, date2 : 필수적인 인수로 날짜식에서 계산에 사용할 두 날짜이다. 
   >> firstdayofweek : 선택적인 인수로 요일을 지정하는 상수로 지정하지 않으면 일

요일로 간주한다. 
   >> firstweekofyear : 선택적인 인수로 연도를 기준으로 한 첫째 주를 지정하는 상

수이다. 
     지정하지 않으면 1월 1일을 포함하는 주를 첫째 주로 간주한다.

  interval 에 가능한 값은 아래와 같다.

   yyyy 년 
   q 분기 
   m 월 
   y 일(일년 기준) 
   d 일 
   w 요일 
   ww 주(일년 기준) 
   h 시 
   n 분 
   s 초


  >> firstdayofweek 에 가능한 값은 아래와 같다.
   =======================================
   상수     값   설명 
  =======================================
  vbUseSystem  0   NLS(National Language Support) API 설정 사용 
  vbSunday     1   일요일(기본값) 
  vbMonday     2   월요일 
  vbTuesday    3   화요일 
  vbWednesday  4   수요일 
  vbThursday   5   목요일 
  vbFriday     6   금요일 
  vbSaturday   7   토요일


  >> firstweekofyear 에 가능한 값은 아래와 같다.

   =======================================
   상수        값  설명 
  =======================================

  vbUseSystem     0  NLS(National Language Support) API 설정 사용 
  vbFirstJan1     1  1월 1일을 포함하는 주에서 시작(기본값) 
  vbFirstFourDays 2  새해의 처음 4일을 포함하는 주에서 시작 
  vbFirstFullWeek 3  새해의 처음 한 주일(7일)을 포함하는 주에서 시작
 
 예)

 DateDiff("h", "2001년 12월 30일", Date) '현재시간과 2001년 12월 30일의 시간차이

비교
 DateDiff("n", "2001년 12월 30일 09:30:00", now) 
 DateDiff("s", "2001년 12월 30일 09:30:00", now)


 ♠ DatePart

 >> 주어진 날짜의 지정된 부분을 반환한다.

 사용법 : DatePart(interval, date[, firstdayofweek[, firstweekofyear]])

 >> interval : 필수적인 인수로 반환할 시간 간격의 문자식이다.
 >> date : 필수적인 인수로 계산할 날짜식이다. 
 >> firstdayof week : 선택적인 인수로 요일을 지정하는 상수로서 지정하지 않으면

일요일로 간주한다. 
 >> firstweekofyear : 선택적인 인수로 연도를 기준으로 한 첫째 주를 지정하는 상수

이다. 
   지정하지 않으면 1월 1일을 포함하는 주를 첫째 주로 간주한다.

  interval 에 가능한 값은 아래와 같다.


   yyyy 년 
   q분기 
   m 월 
   y 일(일년 기준) 
   d 일 
   w 요일 
   ww 주(일년 기준) 
   h 시 
   n 분 
   s 초

  firstdayofweek 에 가능한 값은 아래와 같다.

   =======================================
   상수          값  설명 
  =======================================

  vbUseSystem  0   NLS(National Language Support) API 설정 사용 
  vbSunday     1   일요일(기본값) 
  vbMonday     2   월요일 
  vbTuesday    3   화요일 
  vbWednesday  4   수요일 
  vbThursday   5   목요일 
  vbFriday     6   금요일 
  vbSaturday  7   토요일


  firstweekofyear 에 가능한 값은 아래와 같다.
   =======================================
   상수        값  설명 
  =======================================

  vbUseSystem     0  NLS(National Language Support) API 설정 사용 
  vbFirstJan1     1  1월 1일을 포함하는 주에서 시작(기본값) 
  vbFirstFourDays 2  새해의 처음 4일을 포함하는 주에서 시작 
  vbFirstFullWeek 3  새해의 처음 한 주일(7일)을 포함하는 주에서 시작

 예)

 <%=DatePart("q", now)%> 
 * 실행결과 : 1,2,3,4 의 숫자중 현재 분기에 해당하는 숫자 리턴

 

 ♠ DateSerial

 >>지정된 년, 월, 일의 Date 하위 형식인 Variant를 반환한다. 
   즉 임의의 숫자를 입력받아 날짜 형식으로 반환하는 함수이다.

 사용법 : DateSerial(year, month, day)

  year : 100에서 9999까지의 수 또는 수식 
  month : 모든 수식 
  day : 모든 수식

 예)

 <%=DateSerial(2001, 12, 25) %>
 * 실행결과 : 2001-12-25
 ♠ DateValue

 >>Date 하위 형식의 Variant를 반환한다.

 사용법 : DateValue(date)

 대개 date 인수는 100년 1월 1일에서 9999년 12월 31일까지를 나타내는 문자식으로

이 범위에 있는 
 날짜, 시간 또는 날짜/시간을 나타내는 식이다. 
 date 인수에 시간 정보가 있는 경우 DateValue 함수에서는 그 정보를 반환하지 않는

다. 
 그러나 date 인수에 "12:11"처럼 잘못된 시간 정보가 있으면 오류가 발생하게 된다.

 date 인수가 유효한 날짜 구분 기호로 분리된 숫자만 있는 문자열인 경우, DateValue

함수에서는 
 컴퓨터에 설정한 간단한 표시 날짜 형식에 따라 년, 월, 일에 대한 순서로 인식하게

된다. 
 또한 정식이나 약식의 월 이름을 포함하고 있는 명확한 날짜도 인식한다. 
 예를 들어 DateValue 함수는 1/23/2001과 1/23/01 뿐만 아니라 January 23,2001과

Jan 23,2001을 
 모두 인식한다.

 date 인수에서 연도 부분을 생략할 경우 DateValue 함수는 컴퓨터 시스템에 설정되어

있는 현재 
 연도를 사용한다.

 예)

 <%=DateValue("2000년 12월 25일") %>
 * 실행결과  : 2000-12-25


-----------------------------
엑셀로 저장

<%
'디비에서 데이타를 불러와 엑셀로 저장하기

'ODBC 연결
Set db = Server.CreateObject("Adodb.Connection")
db.open "dsn=nagayodb;uid=sa;pwd=kkk119;"

Response.Buffer = true

'변수 선언
Dim xlApp 
Dim xlWorkbook 
Dim xlWorksheet
Dim sSQL, rs, strHTML, str

'데이타 불러오기
sSQL = "Select * From 테이블명"
Set rs = Server.CreateObject("ADODB.RecordSet")
rs.Open sSQL, db
%>
<html>
<head>
<title>디비에서 데이타를 불러와 엑셀로 저장하기</title>
<body bgcolor=white>
<table border='1' cellpadding='3' cellspacing='1'>
<%
do until rs.EOF
%>
<tr height='30'>
<td><%=rs(0)%></td>
<td><%=rs(1)%></td>
<td><%=rs(2)%></td>
</tr>
<%
rs.MoveNext
loop
%>
</table>

<br>

<a href="work\test.xls" target="_new">엑셀로 보기 </a>

<%
'엑셀로 변환
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True

Set xlWorkbook = xlApp.Workbooks.Add
Set xlWorksheet = xlWorkbook.Worksheets.Add

rs.movefirst
i = 1
do until rs.EOF

a = "A"&i
b = "B"&i
xlWorksheet.Range(a).Value = rs(0)&","&rs(1)
xlWorksheet.Range(b).Value = rs(2)

rs.MoveNext
i = i + 1
loop

xlApp.Workbooks.Item(1).SaveAs Server.MapPath("/work") & "\" & "test.xls"

'Session.SessionID & ".xls"

xlWorkbook.Close false
xlApp.WorkBooks.Close
xlApp.Quit

Set xlWorksheet = Nothing
Set xlWorkbook = Nothing
Set xlApp = Nothing

rs.Close
Set rs = Nothing
%>

반응형
Posted by 친절한 웬디양~ㅎㅎ
|
반응형

 

아래는 http://support.microsoft.com/kb/194799/ko 내용임...

요약

이 문서에서는 삽입하고 Oracle 데이터베이스를 사용할 수 있는 ASP (Active Server Pages) 페이지 RAW 또는 LONG RAW 데이터를 검색하는 방법에 대해 설명합니다.

 

추가 정보

1.
Oracle 테이블을 이미지를 삽입하려면 다음 Microsoft 기술 자료의 다음 문서를 참조하십시오.

185958  (http://support.microsoft.com/kb/185958/EN-US/ ) AppendChunk ADO GetChunk BLOB 데이터용 Oracle 함께 사용하는 방법
참고: 우리는 Microsoft Access를 사용하여 Oracle에 이미지를 삽입할 사용하지 않는 것이 좋습니다. OLE 래퍼를 개체를 추출하여 ASP가 올바르게 해석되지 않도록 개체 주위에 추가됩니다.

2. 쿼리 및 이미지를 표시하는 다음 코드를 사용합니다.: 
  <%@ LANGUAGE="VBSCRIPT" %>

      <%
      'Clear existing HTTP header information.
      Response.Expires = 0
      Response.Buffer = TRUE
      Response.Clear

      'Set the HTTP header to an image type, if you want to display
      'a jpg you need to use the "image/jpeg" content type.
      Response.ContentType = "image/gif"

      Dim strTemp

      Set oConn = Server.CreateObject("ADODB.Connection")

     'You need to change this line to reflect your DSN, UID
     'and PWD.
      oConn.Open "DSN=Ovteam;UID=userid;PWD=password;"

     'Change this line to use your table that contains a raw or
     'long raw field.  In this case, ID is the primary key of the
     'IMAGE table and IMG is the RAW or LONG RAW data column.
      sSQL = "Select ID, IMG from IMAGE where ID = 1"

      Set oRS = Server.CreateObject("ADODB.Recordset")
      oRS.Source = sSQL
      oRS.ActiveConnection = oConn

     'The cursor type does not seem to matter.  A keyset cursor was used
     'with success for this article; however, you will not be able to
     'scroll with it because the content type of this page is set for
     '"image/gif".

      oRS.Open

      strtemp = oRS("IMG")
      Response.BinaryWrite(strTemp)
      Response.End

      oRS.Close
      Set oRS = nothing
      oConn.Close
      Set oConn = nothing
   %>

참고: 이 페이지의 콘텐츠 형식의 변경 때문에 하나의 이미지를 표시할 수 있습니다. 이 텍스트를 페이지에 통합하기 위해 서버 작업이 필요한 다른 페이지에 그림을 얻으려면 이 .asp 페이지의 측면 포함됩니다.
 
자세한 내용은 Microsoft 기술 자료의 다음 문서를 참조하십시오.
192743  (http://support.microsoft.com/kb/192743/EN-US/ ) TEXT 데이터 AppendChunk ADO GetChunk Oracle 함께 사용하는 방법
 

본 문서의 정보는 다음의 제품에 적용됩니다.
  • Microsoft Open Database Connectivity 2.5
  • Microsoft ActiveX Data Objects 2.0
  • Microsoft ActiveX Data Objects 2.1
  • Microsoft ActiveX Data Objects 2.1 서비스 팩 2
  • Microsoft ActiveX Data Objects 2.5
  • Microsoft ActiveX Data Objects 2.6
  • Microsoft ActiveX Data Objects 2.7
  • Microsoft Active Server Pages 4.0
  • Microsoft Data Access Components 2.5
  • Microsoft Data Access Components 2.6
  • Microsoft Data Access Components 2.7
 
키워드: 
kbmt kbcode kbhowto kboracle kbprovider KB194799 KbMtko

반응형
Posted by 친절한 웬디양~ㅎㅎ
|
반응형

'create objects
Set Conn = Server.CreateObject("ADODB.Connection")
set recordset = server.createobject("ADODB.Recordset")

'open connection object to database
conn.open "DSN=theDatabase;User ID=userid;password=password"
sql="select CLOBField from CLOBFieldtable"

'open recordset object
recordset.Open sql, conn

'create the Field object for the CLOB field
clobFieldObject = recordset.Fields("CLOBField")

'Use the GetChunk Method to read the data.
'Pass the size of the data you want to retrieve
'in this case, we are retrieving 50K
strCLOBstring = clobFieldObject.GetChunk(50000)


Editing CLOB fields are a little more complicated because I have to
use the empty_clob() Oracle function to create an empty CLOB field,
and then use the AppendChunk method to write the binary data to the
empty field.  The code looks like this:

'use the same connection and recordset objects as above
sql="Update CLOBFieldtable set CLOBField = empty_clob() where CLOBid =
1"

'no need to use a recordset here
conn.execute(sql)

'get your empty clob field in a recordset to update it.
sql="select CLOBField from CLOBFieldtable where CLOBid = 1"
recordset.Open sql, conn

'Get the field object we want to write to
CLOBFieldObj = recordset.Fields("CLOBField")

'Now use the AppendChunk Method to write your data
CLOBFieldObj.AppendChunk("Some Huge Long String to write to CLOB
field")

'Commit the transaction
recordset.update




=========================================================

Example 1 : Saving the Data in a SQL Server Image Column to a File on the Hard Disk
The code in this example opens a recordset on the pub_info table in the pubs database and saves the binary image data stored in the logo column of the first record to a file on the hard disk, as follows: 1. Open a new Standard EXE Visual Basic project.
2. On the Project menu, click to select References, and then set a reference to the Microsoft ActiveX Data Objects 2.5 Object Library.
3. Place a CommandButton control on Form1.
4. Make the following declarations in the form's General declarations section: Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim mstream As ADODB.Stream


5. Cut and paste the following code into the Click event of the CommandButton that you added to the form: Set cn = New ADODB.Connection
cn.Open "Provider=SQLOLEDB;data Source=<name of your SQL Server>;
Initial Catalog=pubs;User Id=<Your Userid>;Password=<Your Password>"

Set rs = New ADODB.Recordset
rs.Open "Select * from pub_info", cn, adOpenKeyset, adLockOptimistic

Set mstream = New ADODB.Stream
mstream.Type = adTypeBinary
mstream.Open
mstream.Write rs.Fields("logo").Value
mstream.SaveToFile "c:\publogo.gif", adSaveCreateOverWrite

rs.Close
cn.Close


6. Save and run the Visual Basic project.
7. Click the CommandButton to save the binary data in the logo column of the first record to the file c:\publogo.gid. Look for this file in Windows Explorer and open it to view the saved image.

The code in this example declares an ADODB Stream object and sets its Type property to adTypeBinary to reflect that this object will be used to work with Binary data. Following this, the binary data stored in the logo column of the first record in the pub_info table is written out to the Stream object by calling its Write method. The Stream object now contains the binary data that is saved to the file by calling its SaveToFile method and passing in the path to the file. The adSaveCreateOverWrite constant passed in as the second parameter causes the SaveToFile method to overwrite the specified file if it already exists.

Example 2 : Transfer the Image Stored in a .gif File to an Image Column in a SQL Server Table
The code in this example saves an image stored in a .gif file to the logo column in the first record of the pub_info table by overwriting its current contents, as follows: 1. Open a new Standard EXE Visual Basic project.
2. On the Project menu, click to select References, and then set a reference to the Microsoft ActiveX Data Objects 2.5 Object Library.
3. Place a CommandButton on Form1. 
4. Make the following declarations in the form's General declarations section:Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim mstream As ADODB.Stream


5. Cut and paste the following code in the Click event of the CommandButton that you added to the form:Set cn = New ADODB.Connection
cn.Open "Provider=SQLOLEDB;data Source=<name of your SQL Server>;
Initial Catalog=pubs;User Id=<Your Userid>;Password=<Your Password>"

Set rs = New ADODB.Recordset
rs.Open "Select * from pub_info", cn, adOpenKeyset, adLockOptimistic

Set mstream = New ADODB.Stream
mstream.Type = adTypeBinary
mstream.Open
mstream.LoadFromFile "<path to .gif file>"
rs.Fields("logo").Value = mstream.Read
rs.Update

rs.Close
cn.Close


6. Save and run the Visual Basic project.
7. Click on the CommandButton to run the code to stream the contents of the .gif file to the ADO Stream object, and save the data in the Stream to the logo column in the first record of the recordset.
8. Verify that the image in the logo column has been modified by using the code in Example 1.
반응형
Posted by 친절한 웬디양~ㅎㅎ
|
반응형

ASP에서 BLOB필드에 저장된 이미지를 나타내는 방법

 

이 문서는 이전에 다음 ID로 출판되었음: KR601057

요약

Active Server Page(ASP)를 사용하여, BLOB필드에 저장된 Image를 Internet Browser에서 볼 수 있다. 아래의 예제는 Microsoft SQL Server sample database table인 pub_info에 저장된 GIF 이미지를 보여주는 방법을 보여준다.

추가 정보

대부분의 Internet browser들은 GIF와 JPEG 이미지를 지원한다. 이미지를 보여주기 위해서, 브라우저는 웹 서버로부터 이미지를 요청한다. 서버는 HTTP헤더의 MIME형식을 IMAGE/GIF 또는 IMAGE/JPEG를 포함함으로써, 이미지를 브라우저로 보낸다. 이러한 작업들을 Active Server Page를 이용하여 가능하다. 다음의 예제는 이미지에 대한 HTTP헤더를 작성하고 GIF파일을 브라우저에 제공하기 위해서 SQL서버에 있는 Image필드에 있는 이진 정보를 사용한다.
 
FILE: SHOWIMG.ASP
   <%@ LANGUAGE="VBSCRIPT" %>
   <%
   ' Clear out the existing HTTP header information
   Response.Expires = 0
   Response.Buffer = TRUE
   Response.Clear

   ' Change the HTTP header to reflect that an image is being passed.
   Response.ContentType = "image/gif"

   Set cn = Server.CreateObject("ADODB.Connection")
   ' The following open line assumes you have set up a System DataSource
   ' by the name of myDSN.
   cn.Open "DSN=myDSN;UID=sa;PWD=;DATABASE=pubs"
   Set rs = cn.Execute("SELECT logo FROM pub_info WHERE pub_id='0736'")
   Response.BinaryWrite rs("logo")
   Response.End
   %>
 
위의 스크립트는 화면에 이미지만을 보여준다. HTML이나 ASP 문서로부터 이미지를 보여주려고 한다면 <IMAGE> 태그 안에 위의 파일을 참조한다.예를 들어, 이미지를 이 이미지를 설명하는 텍스트와 함께 화면에 나타내려면 다음과 같은 HTML페이지를 사용한다.
   <HTML>
   <HEAD><TITLE>Display Image</TITLE></HEAD>
   <BODY>
   This page will display the image New Moon Books from a SQL Server 6.5
   image field.<BR>
   <IMG SRC="SHOWIMG.ASP">
   </BODY>
   </HTML>
이 방법은 다른 형식의 이진 데이터에도 적용할 수 있다. 이를 위해 필요한 것은 표현될 Content의 형식이 무엇인지를 브라우저에게 알려주는 것이다. Response.ContentType에 적절한 Mine형식을 설정함으로써 브라우저에게 Content형식을 알려줄 수 있다. 예를 들어, 워드 문서를 나타내기 위해서는 ContentType = "application/msword"으로 설정한다.
 
키워드: 
KB601057
반응형
Posted by 친절한 웬디양~ㅎㅎ
|