• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 958
  • Last Modified:

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

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
Nitin Shah
Asked:
Nitin Shah
  • 11
  • 8
  • 4
  • +1
1 Solution
 
mlmccCommented:
What version of Crystal?

mlmcc
0
 
Nitin ShahAuthor Commented:
crystal 8.5, vb6
0
 
Gary PattersonVP Technology / Senior Consultant Commented:
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
Brook BraswellApplication Development ManagerCommented:
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
 
Nitin ShahAuthor Commented:
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
 
mlmccCommented:
You need Crystal XI to do that.  Earlier versions require the image to be stored in the database.

mlmcc
0
 
Nitin ShahAuthor Commented:
dear mlmcc

i will try and revert back

thanks



0
 
Nitin ShahAuthor Commented:
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
 
mlmccCommented:
I don't know how to store a picture in a database.  Some databases have a image or binary datatype.

mlmcc
0
 
Brook BraswellApplication Development ManagerCommented:
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
 
Nitin ShahAuthor Commented:
dear brook1966

i am using ms sql database
0
 
Nitin ShahAuthor Commented:
is anybody can help me out ?
0
 
Brook BraswellApplication Development ManagerCommented:
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
 
mlmccCommented:
It has to he stored as an image.  many databases have a BLOB type that can be used.

mlmcc
0
 
Nitin ShahAuthor Commented:
ms sql does not have data type as BLOB

nitin shah
 
0
 
Brook BraswellApplication Development ManagerCommented:
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
 
Nitin ShahAuthor Commented:
sql 2000 has data type as image . but how to store jpg or other picture file in database
0
 
Brook BraswellApplication Development ManagerCommented:
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
 
Nitin ShahAuthor Commented:
dear brook1966

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

i can see picture in vb data screen correctly


 




0
 
Brook BraswellApplication Development ManagerCommented:
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
 
Brook BraswellApplication Development ManagerCommented:
have you tried creating a report from scratch with the crystal designer - before importing into your app as a dsr?
0
 
Nitin ShahAuthor Commented:
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
 
Brook BraswellApplication Development ManagerCommented:
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
 
Nitin ShahAuthor Commented:
dear brook1966

thanks for help.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 11
  • 8
  • 4
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now