본문 바로가기

asp,ms-sql

asp GetString을 이용하여 레코드셋을 배열에 저장하기

728x90

ConnString = "DB연결문 넣으시구요"

SQL = "select userId, userName from tblUser with(nolock) order by userName"

Set db = Server.CreateObject("ADODB.Connection")
db.Open ConnString
Set Tbl = db.execute(SQL)

if Tbl.Eof or Tbl.Bof then
cnt=0
else
AllRec = Tbl.GetString(2)                ' 레코드셋을 한방에 저장
recRows = split(AllRec, chr(13))
cnt=1
end if
Tbl.close                                             ' 연결을 바로 끊습니다.
set Tbl=nothing

if cnt=1 then
for i=0 to Ubound(recRows)-1        ' 행의 수만큼 루프를 돌려서 데이터를 표시해 줍니다.
recCols = split(recRows(i), chr(9))
response.write "ID:"& recCols(0) &", 이름:"& recCols(1) &"<br>"
next
end if