Solved

how to print picture in vb - crystal report dsr from table

Posted on 2010-09-01
26
892 Views
Last Modified: 2012-06-27
i want to print picture from file whose file name is stored in sql table. i want to each employee foto in vb application using crystal report DSR. how can i print foto in report?
0
Comment
Question by:nitin_s_shah
  • 11
  • 8
  • 4
  • +1
26 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 33579597
What version of Crystal?

mlmcc
0
 

Author Comment

by:nitin_s_shah
ID: 33583391
crystal 8.5, vb6
0
 
LVL 34

Expert Comment

by:Gary Patterson
ID: 33589281
0
 
LVL 14

Expert Comment

by:Brook Braswell
ID: 33590264
Create your report
add an image - any image if you wish
Right click on image
select Format Graphic
Click on Picture Tab
You should see a Formula Button for the Graphic Location
Place your database field here which should hold the Path for where the picture resides.
0
 

Author Comment

by:nitin_s_shah
ID: 33614923
dear brook1966

i want to print it from file whose location is stored in sql table. i want to print it dynamically. this will not work in dsr mode when i want to print picture runtime from employee table.

thanks  
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 33621787
You need Crystal XI to do that.  Earlier versions require the image to be stored in the database.

mlmcc
0
 

Author Comment

by:nitin_s_shah
ID: 33624071
dear mlmcc

i will try and revert back

thanks



0
 

Author Comment

by:nitin_s_shah
ID: 33643656
dear mlmcc

i think it take more time to get crystal xi. can u tell me how to store picture in database and print it runtime in crystal 8.5 version?

thanks



0
 
LVL 100

Expert Comment

by:mlmcc
ID: 33650199
I don't know how to store a picture in a database.  Some databases have a image or binary datatype.

mlmcc
0
 
LVL 14

Expert Comment

by:Brook Braswell
ID: 33650227
I have seen that you can save some pictures in binary format and save them in the database in a big integer field.  SQL Anywhere has this type of field.  What database are you using?
0
 

Author Comment

by:nitin_s_shah
ID: 33659534
dear brook1966

i am using ms sql database
0
 

Author Comment

by:nitin_s_shah
ID: 33679269
is anybody can help me out ?
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 14

Expert Comment

by:Brook Braswell
ID: 33681166
I am looking into storing the picture as a binary data type....
storing is not the problem - making sure you can extract it in a crystal report is the question.
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 33685873
It has to he stored as an image.  many databases have a BLOB type that can be used.

mlmcc
0
 

Author Comment

by:nitin_s_shah
ID: 33688494
ms sql does not have data type as BLOB

nitin shah
 
0
 
LVL 14

Expert Comment

by:Brook Braswell
ID: 33718017
Older versions of SQL Server had an Image data type.
Does yours?

if it does - you can open your file with a stream and save it to your sql server that way.
then crystal will report with the image data field...

I was able to write an image to a Binary data type but could not find a way to show this back as an image in Crystal 8.5
0
 

Author Comment

by:nitin_s_shah
ID: 33719030
sql 2000 has data type as image . but how to store jpg or other picture file in database
0
 
LVL 14

Accepted Solution

by:
Brook Braswell earned 500 total points
ID: 33720486
dim fs as new adodb.stream
dim fName as string
fname = "your file and path"
fs.type = adTypeBinary

Have a connection and a recordset with your Image field

sql = "Select imgField from Table where condition true"
rs.open sql,conn, adOpenStatic, adLockOptimistic

' trap for record not existing from query and what to do when not there...
fs.open
fs.LoadFromFile fName

rs!imgField = fs.read
rs.update
fs.close
0
 

Author Comment

by:nitin_s_shah
ID: 33733980
dear brook1966

i am able to store image but not able to print it

i can see picture in vb data screen correctly


 




0
 
LVL 14

Expert Comment

by:Brook Braswell
ID: 33734133
So you just place the image field in the report like any other field and the picture does not show?....
I tested this with XI and with 2008, I have not tested with 8.5 but remembered that it is supposed to work there also.
My only other thoughts would then be that you may look into upgrading your CR to at least XI
0
 
LVL 14

Expert Comment

by:Brook Braswell
ID: 33734150
have you tried creating a report from scratch with the crystal designer - before importing into your app as a dsr?
0
 

Author Comment

by:nitin_s_shah
ID: 33751057
dear brook1966


thanks for your kind help. i am able to store picture in sql database as per your coding. i am storing picture as well as file location in database. i am able to print in crystal dsr mode.

i accept this as solution to my problem, but can i print picture from file location define in database.

with regards

nitin shah

0
 
LVL 14

Expert Comment

by:Brook Braswell
ID: 33753650
Crystal 8.5 will not allow you to print from a file location.

I have crystal XI and 2008.  Both have an option on image objects that allow a path to be given and have the image refresh on print.  Here is where I normally put the field in the database containing the file location.  "WARNING" make sure the path in the database is available to users of the report.
Best Practice is to NOT put drive letter designation but rather the UNC path.
NOT D:\SharedPath\Picturename.jpg
DO \\ServerName\SharedPath\Picturename.jpg


Happy Coding :)
0
 

Author Comment

by:nitin_s_shah
ID: 33759320
dear brook1966

thanks for help.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now