krkumar50 Level: Trainee
 Registered: 23-09-2006 Posts: 3
|
placing images in crytal report
'pl help me
' this code is for displaying images in crytal report from vb with sql server. but image is not displayed.
database
------------
eno ename photo
1 a test.jpg
2 b test1.bmp
-------------------------------
the problem is in the SECT_FORMAT function
error message is :
runtime error 9
subscript out of range
-------------------------------------
'code for module
Public cn As New ADODB.Connection
Dim cmd1 As New ADODB.Command
Dim rst1 As New ADODB.Recordset
Dim p1 As ADODB.Parameter
Dim db As craxdrt.Database
Dim rpt As craxdrt.Report
Dim appl As craxdrt.Application
Dim WithEvents sect As craxdrt.Section
Private Sub Form_Load()
cn.Open "dsnpayroll"
cmd1.ActiveConnection = cn
cmd1.CommandType = adCmdStoredProc
cmd1.CommandText = "usp_searchData"
Set appl = New craxdrt.Application
Set rpt = appl.OpenReport("d:\ReportImage" & "\Report1.rpt")
Set db = rpt.Database
Set sect = rpt.Sections("Section5")
If rst1.State = 1 Then rst1.Close
Set p1 = cmd1.CreateParameter("sql", adVarChar, adParamInput, 400)
cmd1.Parameters.Append p1
p1.Value = "select *from employee"
Set rst1 = cmd1.Execute
cmd1.Parameters.Delete "sql"
Set p1 = Nothing
If rst1.State = 1 Then rst1.Close
CRViewer1.ReportSource = rpt
CRViewer1.ViewReport
CRViewer1.Zoom 1
Me.WindowState = 2
Screen.MousePointer = vbHourglass
Screen.MousePointer = vbDefault
End Sub
Private Sub Form_Resize()
CRViewer1.Top = 0
CRViewer1.Left = 0
CRViewer1.Height = ScaleHeight
CRViewer1.Width = ScaleWidth
End Sub
Private Sub sect_Format(ByVal pFormattingInfo As Object)
Dim bmp As StdPicture
With sect.ReportObjects
Set bmp = LoadPicture("d:\ReportImage\Photo\" & .Item("Field3").Value) 'path for images
Set .Item("Picture1").FormattedPicture = bmp
End With
End Sub
thanks a lot
|