Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > Crystal Reports
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Crystal Reports General discussion about Crystal Reports. For discussions specific to the book Professional Crystal Reports for VS.NET, please see the book discussion forum for that book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Crystal Reports section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 20th, 2005, 09:28 AM
ERC ERC is offline
Authorized User
 
Join Date: Jan 2005
Location: West Sussex, , United Kingdom.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default Picture Objects - how do I change the image on a r

I need to use a logo on my reports - a different image needs to be displayed for different reports.

I created a picture object but can't find a way to set the picture at run time. I am using VB.NET and CR10.

Any ideas?
Reply With Quote
  #2 (permalink)  
Old January 27th, 2005, 01:15 PM
ERC ERC is offline
Authorized User
 
Join Date: Jan 2005
Location: West Sussex, , United Kingdom.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Incase anyone has the same problem this is the solution:

Dim data As New DataSet()
Dim row As DataRow

data.Tables.Add("Images")
data.Tables(0).Columns.Add("img", System.Type.GetType("System.Byte[]"))

Dim fs As New FileStream("C:\test.jpg", FileMode.Open)
Dim br As New BinaryReader(fs)

row = data.Tables(0).NewRow()
row(0) = br.ReadBytes(br.BaseStream.Length)
data.Tables(0).Rows.Add(row)

br.close
fs.close

br = Nothing
fs = Nothing

' CrystalReport1 is a strongly typed report created in Visual Studio.
Dim cr As New CrystalReport1()
cr.SetDataSource(data)
CrystalReportViewer1.ReportSource = cr
Reply With Quote
  #3 (permalink)  
Old February 11th, 2005, 02:46 PM
Registered User
 
Join Date: Feb 2005
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

you are using a non typed dataset, how you create the report without a typed dataset, I try to do this with a typed ds but the type byte from the typ ds doesnt accept the data

is htere a way to create a cryst r whitout a typed dataset? so you can create a dataset manualy and use it from the report like you are doing?? how you do that?
please be more specific with the cryst r part thanks


Reply With Quote
  #4 (permalink)  
Old February 14th, 2005, 05:15 AM
ERC ERC is offline
Authorized User
 
Join Date: Jan 2005
Location: West Sussex, , United Kingdom.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

CrystalReport1 is an rpt that is embedded in my VB.net project - so i created it by choosing 'add new item' and then selecting 'crystal report'.

I then added another new item - an Xml schema - in the same way. Once the schema is created, right click on it and select add, new element. This is a data table so fill it with column names and data types that you need.

Then attach this data table to your report so that you can do the design work.

Hope this helps


Reply With Quote
  #5 (permalink)  
Old March 14th, 2005, 12:22 PM
Registered User
 
Join Date: Mar 2005
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm unsure what CrystalReportViewer1 is or how the image actually gets displayed on the report. You set the data to the report with the image in the data, but then how do you display that data?
Reply With Quote
  #6 (permalink)  
Old March 15th, 2005, 10:40 AM
ERC ERC is offline
Authorized User
 
Join Date: Jan 2005
Location: West Sussex, , United Kingdom.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

CrystalReportViewer1 is a control that you can drop onto a form - to display the report to the user.

This is exactly what i did:

1. Created XSD called 'GeneralSchema'. Created table inside XSD called 'ReportHeader'. Created the element 'Logo' in the table. Logo has the datatype HexBinary.

2. Created rpt and added the 'ReportHeader' table using the Database Expert.

3. At runtime:

Dim ds as Dataset
Dim tbl As DataTable
Dim row As DataRow


Dim path As String = "C:\logos\logo1.jpg"
'i'm actually getting the logo path from a sql table but have put this here for simplicity

'create data table as 'Report Header' table in 'General Schema'
tbl = New GeneralSchema.ReportHeaderDataTable
row = tbl.NewRow()

'set logo
If path <> "" Then
Dim fs As New FileStream(path, FileMode.Open)
Dim br As New BinaryReader(fs)

row("logo") = br.ReadBytes(br.BaseStream.Length)

br.Close()
fs.Close()

br = Nothing
fs = Nothing
Else
row("logo") = ""
End If

'add the table to the dataset
tbl.Rows.Add(row)
ds.Tables.Add(tbl)
rpt.SetDataSource(ds)

Hope this helps

Reply With Quote
  #7 (permalink)  
Old March 15th, 2005, 02:44 PM
Authorized User
 
Join Date: Jul 2004
Location: , WI, USA.
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Insert that picture in a seperate section. In the properties of that section, (Right Click->Format Section) check the box that says - underlay following sections.

This puts the section behind all the sections that follow and so the image is displayed in the background as logo.

Gauri

Reply With Quote
  #8 (permalink)  
Old March 18th, 2005, 10:56 AM
Registered User
 
Join Date: Mar 2005
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I named a .xsd file "GeneralSchema" and created a table called ReportHeader just like you specified. However, when I type

tbl = New GeneralSchema.ReportHeaderDataTable

the IDE does not even recognize "GeneralSchema" as a valid object - it's not showing up. Is there some public property I have to set so it will be recognized?

Thanks for all your help!

Reply With Quote
  #9 (permalink)  
Old March 18th, 2005, 11:06 AM
ERC ERC is offline
Authorized User
 
Join Date: Jan 2005
Location: West Sussex, , United Kingdom.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Right click in the xsd schema (not on the table) and make sure the 'Generate Dataset' option is ticked (at bottom of list). If it is ticked then untick it and then tick it again just to recreate the dataset.

Note - if you click 'show all files' at the top of your solution explorer you should find that there is now a VB file under your xsd file.

Now try typing tbl = New GeneralSchema.ReportHeaderDataTable again. If it still doesnt recognise it try closing Visual Studio and then re-opening it.

Hope this helps!
Reply With Quote
  #10 (permalink)  
Old March 18th, 2005, 11:26 AM
Registered User
 
Join Date: Mar 2005
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Everything compiled great, except that the picture is not showing up. Is there a control I have to add to the rpt to make the picture appear? The only control I have so far is the CrystalReportViewer on the asp file; ie, I haven't touched the rpt file except teh link the databases. I have a feeling there must be something that needs to be added to the rpt to make the picture appear.

Thanks for your help!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Wipe off the Picture objects from Excel Sheet Amjad.Mahmoood Excel VBA 4 September 11th, 2006 03:39 AM
image or picture zoom selamiduvar Pro VB 6 2 June 16th, 2006 06:14 AM
Change picture at run-time with CR for .NET? NTurnbullJr Crystal Reports 2 March 31st, 2005 05:29 AM
Picture change derek Flash (all versions) 5 April 22nd, 2004 11:37 AM
default setting change picture/ fax viewer editor mateenmohd Classic ASP Basics 0 June 14th, 2003 03:15 PM



All times are GMT -4. The time now is 01:06 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.