Publish date: 2003-01-05

Arrays reading (VB)

Sub sample5()
 Dim cn As New ADODB.Connection

 ' use file with parameters of connection
 cn.Open "file name=e:\database\employee.ibp"

 Dim cmd As New ADODB.Command

 cmd.ActiveConnection = cn

 'read JOB.LANGUAGE_REQ VARCHAR (15) [1:5]
 cmd.CommandText = "select job_code,language_req from job"

 Dim rs As ADODB.Recordset

 Set rs = cmd.Execute

 Debug.Print "JOB.LANGUAGE_REQ --------------"

 ' copy of data of array field. Call of rs("language_req") always download
 Dim lang_req As Variant

 While Not rs.EOF
  Debug.Print "JOB_CODE:" & CStr(rs("job_code"))
  Debug.Print "LANGUAGE_REQ:"

  lang_req = rs("language_req")

  If (IsNull(lang_req)) Then
   Debug.Print ">[NULL]"
  Else
   Dim i As Long
   ' Walk of elements of array
   For i = LBound(lang_req) To UBound(lang_req)
    Debug.Print ">" & lang_req(i)
   Next i
  End If

  Debug.Print "----------------"
  rs.MoveNext
 Wend
End Sub 'sample5