% 'CREATE TABLE nums(num INTEGER NOT NULL,PRIMARY KEY(num)); 'INSERT INTO nums VALUES(11); 'INSERT INTO nums VALUES(12); 'INSERT INTO nums VALUES(21); 'INSERT INTO nums VALUES(22); 'INSERT INTO nums VALUES(23); 'INSERT INTO nums VALUES(31); function query(sqlstr) Set con = Server.CreateObject("ADODB.Connection") con.Open "Driver={MySQL ODBC 5.3 ANSI Driver};Database=Test;User Id=root;Password=xxxxxx;" Set rs = Server.CreateObject("ADODB.Recordset") rs.Open sqlstr, con if rs.EOF then redim res(0, 2) else res = rs.GetRows() end if Set rs = Nothing Set con = Nothing query = res end function function getColA() getColA = query("SELECT num FROM nums WHERE num BETWEEN 10 AND 19") end function function getColB() getColB = query("SELECT num FROM nums WHERE num BETWEEN 20 AND 29") end function function getColC() getColC = query("SELECT num FROM nums WHERE num BETWEEN 35 AND 39") end function function getVal(x, i) if i <= ubound(x, 2) then getVal = x(0, i) else getVal = "" end if end function %> <% dim a, b, c a = getColA() b = getColB() c = getColC() dim n n = ubound(a, 2) if ubound(b, 2) > n then n = ubound(b, 2) end if if ubound(c, 2) > n then n = ubound(c, 2) end if %>
A | B | C |
---|---|---|
<%=getVal(a, i)%> | <%=getVal(b, i)%> | <%=getVal(c, i)%> |