RecSet Function:
Returns a two-dimensional array representing the resultant recordset of an SQL query.
Description:
The RecSet Function returns a two-dimensional array representing the resultant recordset of an SQL query. There are two required arguments, connstring which must be a valid OLE database connection string, and SQL which must be an SQL statement. If no records are found, RecSet returns Null.
Syntax:
array = RecSet(connstring, SQL)
Example:
<%
dim ar, i, j, cn, strSQL
cn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & server.mappath("/database/mydata.mdb") & ";" strSQL = "SELECT exampleName, exampleDesc FROM examples ORDER BY exampleName;" ar = RecSet(cn, strSQL)
If IsNull(ar) Then '--- no results found response.write "<P STYLE=""font-size:10pt;"">" & vbCrLf response.write "No Results Found!" & vbCrLf response.write "</P>" & vbCrLf Else response.write "<P STYLE=""font-size:10pt;"">" & vbCrLf For j = 0 to ubound(ar, 2) For i = 0 to ubound(ar, 1) response.write ar(i, j) & vbCrLf response.write "<BR>" & vbCrLf Next response.write "<BR>" & vbCrLf Next response.write "</P>" & vbCrLf End If
%>
ASP Source Code:
<%
Private Function RecSet(byVal connstring, byVal SQL) Dim DebugRs, Tmp Set DebugRs = Server.CreateObject("ADODB.Recordset") With DebugRs .CursorType = 3 '--- adOpenStatic .CursorLocation = 2 '--- adUseServer .LockType = 1 '--- adLockReadOnly .ActiveConnection = connstring .Source = SQL .Open If .BOF then Tmp = Null Else Tmp = .GetRows() End If .Close End With Set DebugRs = Nothing RecSet = Tmp End Function '--- RecSet
%>
|