Welcome! and rules
Joel on Software
Image in crystal report
I'm using C# in VS .NET 2003. I want to show some picture in Crystal Report that comes with VS.NET 2003. These pictures locations comes from database. But how I can show images in Crystal Report.
Is there any easy way that I can easily show images in crystal report.net without messing up with various stream readers??
Jamil Salah Uddin
Saturday, March 5, 2005
The easiest way would be to put the images in the database not just their locations. Then you can just put the field on the report and it would work correctly.
Not being able to refer to locations to load images was a major problem in crystal and was just fixed with Crystal 11, but I haven't seen it.
Friday, March 11, 2005
I was doing your way but didnt work , I stored a Picture in SQL Server 2000 as an image data type by conveting the picture to binary and i retrieved it correctly into a form, and displayed it in a picture box, but in a report I failed can you explain more about this subject
thanx in advanced
Wednesday, April 6, 2005
I had a project in VB6 with that requirement, i don't remember the details but i do remember it was a pain. I was using CR8.5. I'll dig up the details and post em.
Saturday, April 9, 2005
ok, i found it. Sorry, it's in VB6. Enjoy!
Couple of Notes:
In VB6 you will need to add a reference to cpeaut32.dll, as well as ActiveX Data Objects library.
The SetLogOnInfo method just overrides the report and all sub-reports' database connections to match the database and authentication that the application is already using.
The LoadEntity method will search the report header for a sub-report object named "entity". Once found it creates an ADODB.Recordset with the two fields and pumps it to the sub-report.
The image file must be a bitmap. The "entity" sub-report will need to use pdsmon.dll (ADO, RDO, DAO). Server type is Active Data (Field Definitions Only). I can't seem to find the ttx definition file, but it would look something like this:
EntityName String 50 Your Company Name
If you want a copy of the "entity" sub-report i can send it, just email me. If you want a working example, i'm open to being convinced :)
You can use these like so:
Public Function OpenReport(ByVal sReportPath As String, ByVal sLogoPath As String, ByVal sEntityName As String, ByRef oSessionMgr As clsSessionMgr) As CRPEAuto.Report
Dim oCrApp As New CRPEAuto.Application
Dim oCrRpt As CRPEAuto.Report
Set oCrRpt = oCrApp.OpenReport(sReportPath)
SetLogOnInfo oCrRpt, oSessionMgr
LoadEntity oCrRpt, sLogoPath, sEntityName
Set OpenReport = oCrRpt
Private Sub SetLogOnInfo(ByRef oCrRpt As CRPEAuto.Report, ByRef oSessionMgr As clsSessionMgr)
Dim X As Integer
Dim Y As Integer
oCrRpt.Database.Tables(1).SetLogOnInfo oSessionMgr.Server, oSessionMgr.Database, oSessionMgr.UserName, oSessionMgr.Password
For X = 1 To oCrRpt.Sections.Count
For Y = 1 To oCrRpt.Sections.Item(X).ReportObjects.Count
If TypeOf oCrRpt.Sections.Item(X).ReportObjects.Item(Y) Is CRPEAuto.SubreportObject Then
SetLogOnInfo oCrRpt.OpenSubreport(oCrRpt.Sections.Item(X).ReportObjects.Item(Y).Name), oSessionMgr
Private Sub LoadEntity(ByRef oCrRpt As CRPEAuto.Report, ByVal sLogoPath As String, ByVal sEntityName As String)
Dim rs As ADODB.Recordset
Dim oCrSubRpt As CRPEAuto.Report
Dim o As Object
For Each o In oCrRpt.Sections("RH").ReportObjects
If o.Kind = crSubreportObject Then
If LCase(o.Name) = "entity" Then
Set rs = New ADODB.Recordset
rs.Fields.Append "EntityLogo", adLongVarBinary, 2147483647
rs.Fields.Append "EntityName", adVarChar, 50
rs("EntityName").Value = sEntityName
Set oCrSubRpt = oCrRpt.OpenSubreport(o.Name)
oCrSubRpt.Database.Tables.Item(1).SetPrivateData 3, rs
Private Function GetPicBytes(ByVal sLogoPath As String) As Byte()
Dim r() As Byte
Dim s As String
ReDim r(0) As Byte
s = " "
Open sLogoPath For Binary Access Read As #1
Do While Not EOF(1)
Get #1, UBound(r) + 1, s
r(UBound(r)) = CByte(Asc(s))
ReDim Preserve r(UBound(r) + 1)
GetPicBytes = r
Saturday, April 9, 2005
Fog Creek Home