Monday, December 17, 2007

How to save a table into a 2-dimensional array

How to save a table into a 2-dimensional array

S T E P - 1

- First, we will need create a recordset.

<%

Const adOpenKeyset = 1, adLockPessimistic = 2

Dim oConn

Dim oRs

Set oConn = Server.CreateObject("ADODB.Connection")

oConn.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("cp.mdb")

Set oRs = Server.CreateObject("ADODB.Recordset")

oRs.Open "member", oConn, adOpenKeyset, adLockPessimistic

%>

S T E P - 2

- We use the GetRows method to retrieve a table into a 2-dimensional array.

<%

arrGetRs = oRs.GetRows

intUB = UBound(arrGetRs,2)

For i = 0 to intUB

Response.Write "First Column = " & arrGetRs(0,i) & "
"

Response.Write "Second Column = " & arrGetRs(1,i) & "
"

Response.Write "Third Column = " & arrGetRs(2,i) & "
"

Response.Write "Fourth Column = " & arrGetRs(3,i) & "

"

Next

oRs.Close

Set oRs = Nothing

oConn.Close

Set oConn = Nothing

%>


No comments: