<% ' Generic Database - Function Library ' Notice: (c) 2001 Eli Robillard, All Rights Reserved. ' E-Mail: genericdb@rogers.com ' URL: http://www.genericdb.com/ ' GenericFunctions.asp Contents: ' function gdbAutokey(z) ' function gdbAutokey8 ' function gdbAutokey16 ' function gdbDisplay(strPre, strVar, strSuf) ' sub gdbGetOptionTags (pConn, pTbl, fldVal, fldDisplay, fldWhere, fldOrderBy) ' function gdbIsDark (inCol) ' sub gdbNoCache() ' function gdbiif(test,tval,fval) ' GenericCommon.asp Contents: ' function gdbBuildLink(invar) ' function gdbSterilizeText (inVal) ' function gdbVerifyActiveSession(strFile,strMessage) function gdbAutokey(z) ' (c) 2001 Eli Robillard, Use subject to terms of the GNU Lesser Public License ' Returns a random z-character string, defaults to 16-char dim newVal, x, y if z & "x" = "x" then z=16 Randomize Timer newVal="" for x = 1 to z y = Int(36 * Rnd + 1) newVal = newVal & Mid("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",y,1) next gdbAutokey = newVal end function function gdbAutokey8 ' (c) 2001 Eli Robillard, Use subject to terms of the GNU Lesser Public License ' Returns a random 8-character string ' 36^8 = 2,821,109,907,456 unique values dim newVal, x, y Randomize Timer newVal="" for x = 1 to 8 y = Int(36 * Rnd + 1) newVal = newVal & Mid("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",y,1) next gdbAutokey8 = newVal end function function gdbAutokey16 ' (c) 2001 Eli Robillard, Use subject to terms of the GNU Lesser Public License ' Returns a random 16-character string ' 36^16 = 7,958,661,109,946,400,884,391,936 unique values dim newVal, x, y Randomize Timer newVal="" for x = 1 to 16 y = Int(36 * Rnd + 1) newVal = newVal & Mid("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",y,1) next gdbAutokey16 = newVal end function function gdbDisplay(strPre, strVar, strSuf) ' (c) 2001 Eli Robillard, Use subject to terms of the GNU Lesser Public License ' Display three items concatenated. I use it to build links (open tag, variable, close tag). ' If the middle variable is blank, it doesn't display anything. if Trim(strVar) & "x" <> "x" then Response.write strPre & strVar, strSuf end if end function sub gdbGetOptionTags (pConn, pTbl, fldVal, fldDisplay, fldWhere, fldOrderBy) ' (c) 2001 Eli Robillard, Use subject to terms of the GNU Lesser Public License ' Generate the option tags for a combo box from a table dim strsql, conn, rs, numrows, numcols, x, dispcol ' Build query if fldVal = fldDisplay then strsql = "SELECT " & fldVal & " FROM " & pTbl dispcol = 0 else strsql = "SELECT " & fldVal & "," & fldDisplay & " FROM " & pTbl dispcol = 1 end if if fldWhere & "x" <> "x" then strsql = strsql & " WHERE " & fldWhere if fldOrderBy & "x" <> "x" then strsql = strsql & " ORDER BY " & fldOrderBy response.write strsql ' Run query set conn = Server.CreateObject("ADODB.Connection") conn.Open pConn set rs = conn.Execute(strsql) if NOT rs.EOF then arrTags = rs.GetRows numcols=ubound(arrTags,1) numrows=ubound(arrTags,2) else numcols=-1 numrows=-1 end if ' Close dataset rs.Close set rs = Nothing conn.Close set conn = Nothing if numrows > -1 then for x = 0 to numrows %>