<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> <% ' set oConn connection to db.mdb set oConn = Server.CreateObject("ADODB.Connection") oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.Mappath("../../../private/database/db.mdb") & ";" Function create_unique() 'generate a random string to create unique file name randomize SD_count = 1 DO 'get random number b/w 48 & 122 (0 - Z) intRnd = int(75 * rnd + 48) 'limit string to 0-9, a-z, A-Z if (intRnd < 57 OR intRnd > 65) AND (intRnd < 90 OR intRnd > 97) then listRnd = listRnd & chr(intRnd) SD_count = SD_count + 1 END IF 'make random string 15 chars gives 768,909,704,948,766,668,552,634,368 possible combinations on UNIX (case sensitive) or 221,073,919,720,733,357,899,776 combinations under Windows - should be enough ) LOOP UNTIL SD_count = 16 'make it a little more readable create_unique = mid(listRnd,1,5) & "-" & mid(listRnd,6,5) & "-" & mid(listRnd,11,5) End Function Function fmtDateTime(byval d, byval pat) Dim Tokens, token, delim, i, date_part, time_part, DateTokens, TimeTokens ' do not treat Null values as erroneous parameters, handle them gracefully If IsNull(d) Then fmtDateTime = "" Exit Function End If If Not IsDate(d) Then fmtDateTime = "Invalid date parameter." Exit Function End If ' if there's a space in the string, then we're dealing with ' date *and* time formatting, otherwise it date OR time formatting ' we doing If InStr(pat, " ") > 0 Then Tokens = Split(pat, " ") ' should be 2 tokens --> (0)date (1)time Else Tokens = Split(pat, "") ' date OR time formatting End If bIsDate = False : bIsTime = False For Each token In Tokens If InStr(token, "-") > 0 Or InStr(token, "/") > 0 Then ' get the delimter used... If InStr(token, "-") Then delim = "-" ElseIf InStr(token, "/") Then delim = "/" End If ' tokenize the date parts DateTokens = Split(token, delim) For i = 0 To UBound(DateTokens) ' replace the time tokens with properly formatted values Select Case CStr(DateTokens(i)) Case "yy" DateTokens(i) = Right(CStr(DatePart("yyyy", d)), 2) Case "yyyy" DateTokens(i) = CStr(DatePart("yyyy", d)) Case "m" DateTokens(i) = CStr(DatePart("m", d)) Case "mm" DateTokens(i) = ZeroPad(CStr(DatePart("m", d)),2) Case "d" DateTokens(i) = CStr(DatePart("d", d)) Case "dd" DateTokens(i) = ZeroPad(CStr(DatePart("d", d)),2) Case Else fmtDateTime = "Invalid date format : " & token Exit Function End Select Next date_part = Join(DateTokens, delim) End If If InStr(token, ":") > 0 Then ' tokenize the time parts TimeTokens = Split(token, ":") For i = 0 To UBound(TimeTokens) ' replace the time tokens with properly formatted values Select Case CStr(TimeTokens(i)) Case "h" TimeTokens(i) = Right(CStr(DatePart("h", d)), 2) Case "hh" TimeTokens(i) = ZeroPad(CStr(DatePart("h", d)),2) Case "m", "mm" ' always zero-pad minutes TimeTokens(i) = ZeroPad(CStr(DatePart("n", d)),2) Case "s", "ss" ' always zero-pad seconds TimeTokens(i) = ZeroPad(CStr(DatePart("s", d)),2) Case Else fmtDateTime = "Invalid time format : " & token Exit Function End Select Next time_part = Join(TimeTokens, ":") End If Next fmtDateTime = Trim(date_part & " " & time_part) End Function Function ZeroPad(byval str, byval iSize) ZeroPad = String((iSize - Len(str)), "0") & Trim(str) End Function 'set how many row display MaxPage=9 MaxPage2=5 %>