======方法一:取資資庫記錄到陣列中======
* 程式流程圖
* 原碼
Function getdb(fieldstr,comstr,fileNamet) '//getdb(資料庫欄位名稱(陣列型態),SQL命令,資料庫檔案位置)
ReDim createUsers(0) : rlcnt = 0
getF1Ary = fieldstr
Set conn=GetMdbConnection(fileNamet) '//搭配db_function 使用
Set rs1=GetSQLServerStaticRecordset(conn,comstr) '//搭配db_function 使用
dbcheck=false
IF NOT rs1.EOF THEN
FOR a1 = 1 TO rs1.RecordCount
getSte = ""
FOR gf1 = 0 TO Ubound(getF1Ary)
getOne = getF1Ary(gf1)
IF getSte="" THEN
getSte = rs1(getOne)
ELSE
getSte = getSte & "<.>" & rs1(getOne)
END IF
NEXT
IF createUsers(rlcnt)<>"" THEN
rlcnt = rlcnt + 1
ReDim Preserve createUsers(rlcnt)
END IF
createUsers(rlcnt) = getSte
rs1.Movenext
NEXT
else
dbcheck=true
END IF
rs1.close()
set rs1=nothing
getdb=createUsers
End Function
======方法二:取單一欄位======
* 程式流程圖
* 原碼
'只取單一欄紀錄
Function getDataConp(FieldName,cmdstr) '//getDataComp(欄位名稱,SQL指令)
Set npf=server.createObject("ADODB.RECORDSET")
npf.open cmdstr,copc,3,2
IF not npf.EOF THEN
datavalue=npf(FieldName)
END IF
npf.close()
getDataConp=datavalue
End Function