We help IT Professionals succeed at work.

display picture by string field

alvinng
alvinng asked
on
My company uses VB6, Crystal Report8.5, MS SQL Server as development tools. I can't insert the photo files into MS SQL server because of company policy. Now, I would like to display the photo in Crystal Report by these string field in a table.

Table structure like the following sample.

create table PhotoTable
(
 KeyField int,
 PhotoField varchar(50) null
)

Here is its data.
KeyField        PhotoField
1               "c:\photo_dir\1.jpg"
2               "c:\photo_dir\2.jpg"
3               "c:\photo_dir\3.jpg"
4               "c:\photo_dir\4.jpg"
5               "c:\photo_dir\5.jpg"

There is a directory to place all photos files.

SQL statement is
"Select KeyField, PhotoField from PhotoTable"
I want to display some selected photos in detail section.

I find that there is no way to convert string field into a photo.

I can't use OLE because it set the file name during design time.

I can't use blob field because it is company policy.

Is there anyone help?
Comment
Watch Question

Commented:
You can do it in VB, but you will be using the API that Crystal wants you to pay a licensing fee for if you distribute the app.  Here's the code:

Private Sub Command1_Click()
  Dim crApp As New CRAXDRT.Application
  Dim crRep As CRAXDRT.Report
  ' load a standalone report created in the designer
  Set crRep = crApp.OpenReport("c:\crw_samples\test.rpt")
  CRViewer1.ReportSource = crRep
  crRep.VerifyOnEveryPrint = True
 
  ' Add a picture to Page Header
  crRep.Sections.Item(2).AddPictureObject "c:\logo.jpg", 100, 100
 
  ' Add a picture to Detail
  crRep.Sections.Item(3).AddPictureObject "c:\logo.jpg", 100, 100
 
  ' print preview
  CRViewer1.ViewReport
End Sub

You would have to replace "c:\logo.jpg" with the appropriate file name.  Your section numbers might be different too - depends on how you put your report together.

DRRYAN3

Author

Commented:
Dear DRRYAN3!

Of course I can replace picture by vb code. However, I do not know how many pictures get by SQL query and prepare enough space to display the pictures as I will change WHERE clause by vb code. For example.

Example 1.
Select KeyField, PhotoField from PhotoTable
where KeyField > 0

Example 2.
Select KeyField, PhotoField from PhotoTable
where KeyField in (1, 2, 5)

Example 3.
Select KeyField, PhotoField from PhotoTable
where KeyField = 4

Is there any function to change "c:\photo_dir\1.jpg" to a picture rather than a string??

Thanks

Alvin

Commented:
This question has been open now for months without a resolution and/or an accepted answer and will be submitted to the Cleanup section for closure.

My recommendation:  PAQ & refund

DRRYAN3
Commented:
PAQ'd and points refunded as proposed

modulo

Community Support Moderator
Experts Exchange

Explore More ContentExplore courses, solutions, and other research materials related to this topic.