user210313
user210313

Reputation:

Data report in VB 6.0

I'm using data report in VB 6 and trying to display images from database. It retrieves the image but showing the same image for all output the code i'm using are given below

Dim rs As ADODB.Recordset, rs1 As ADODB.Recordset

Dim a As String
k = 0
i = 0
j = 0
k = 0



Set rs = New ADODB.Recordset

With rs

    .CursorType = adOpenDynamic
    .LockType = adLockOptimistic
    .ActiveConnection = conn
    .Source = "SELECT patientid FROM Inpatients_Maintenance WHERE (ModDate >= '" & frmDate & "') AND (ModDate <= '" & endDate & "')"
    .CursorLocation = adUseClient
    .Open

    Do Until rs.EOF

    If (rs.EOF = False And rs.BOF = False) Then
    pid(i) = rs.Fields(0).Value

    End If
    i = i + 1
    rs.MoveNext

    Loop
End With

Set rs = Nothing
Set rs1 = New ADODB.Recordset

Dim id As String
With rs1
    .CursorType = adOpenDynamic
    .LockType = adLockOptimistic
    .ActiveConnection = conn

    For j = 0 To i - 1
        id = pid(j)
       .Source = "Select photo from patientImage where patientid='" & id & "'"
       .CursorLocation = adUseClient
       .Open


        If (rs1.EOF = False And rs1.BOF = False) Then
            p(j) = App.Path + "\patients\" + rs1.Fields(0).Value
            a = p(j)

            Set RptInpatientMaster.Sections("Section1").Controls("Image2").Picture = LoadPicture(a)

        End If
        .Close
    Next j
End With

Upvotes: 1

Views: 3362

Answers (1)

Alex Muni
Alex Muni

Reputation: 474

Do you only see the last one?

Set RptInpatientMaster.Sections("Section1").Controls("Image2").Picture = LoadPicture(a)

you always refer to same picture inside your report, isn't it?

Upvotes: 1

Related Questions