?
Solved

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

Posted on 2010-09-01
26
Medium Priority
?
945 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 11
  • 8
  • 4
  • +1
26 Comments
 
LVL 101

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 35

Expert Comment

by:Gary Patterson
ID: 33589281
0
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
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 101

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 101

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
 
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 101

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 2000 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

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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A recent questions about how to add SSRS named instances, couldn't find any that talks about SQL server 2008, anyway I decided to help by creating some screen shots. The installation is straightforward, you just pop the SQL server 2008 installati…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

801 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