Writing Code
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Writing Code
Message Icon Topic: New to Crystal Reports Seeking Advice Post Reply Post New Topic
Author Message
kmckenzie
Newbie
Newbie
Avatar

Joined: 31 Jan 2007
Location: United States
Online Status: Offline
Posts: 2
Quote kmckenzie Replybullet Topic: New to Crystal Reports Seeking Advice
    Posted: 31 Jan 2007 at 8:01am
Hello all.
 
I am new to Crystal Reports.  I have NEVER used it before!  So...I am in need of creating a report based off of a dataset result.  All database connections are handled by a class, and the datasets are handled in another.  Heres the senario .  I have a form that uses a dataset to fill some properties, which in turn are used to bind some text boxes.  This form has all the needed information I need to create the report and print (a single record).  I'm not sure how to pass the properties to a report.
 
I've created a report and used the class as the datasource.  I put those fields on the form, but I can't get any data to fill those fields.  Do I need to create a new query somewhere in the report and use a parameter to extract the data?  Does Bischof book cover this in detail, and could I understand it with out having to read 500 pages?  I'm kinda on a time limit, but would be interested in learning more in the near future.
 
BTW, My code is VB .NET and I am access a local Access database.
 
Thanks for any help you could provide.
 
Ken McKenzie
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 31 Jan 2007 at 8:47am
Hey Ken,

Since you're brand new to CR, you probably want to pick up a copy of my book b/c you'll probably have lots of questions as you keep working with reports. But it sounds like for now you just need something quick and dirty.

The part you still need to do is populate the DataSet object prior to passing it to the report. It sounds like your code is already populating the dataset, so now pass it to the report object using the SetDataSource(dataset) method. This passes the data to the report for viewing. Here is a quick summary of the steps:

1. Private myReport as ReportDocument = new ReportDocument()
2. myReport.Load(filepath)
3. Load data into myDataSet
4. myReport.SetDataSource(myDataset)
5. CrystalReportViewer1.ReportSource = myReport



Edited by BrianBischof - 31 Jan 2007 at 8:49am
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
kmckenzie
Newbie
Newbie
Avatar

Joined: 31 Jan 2007
Location: United States
Online Status: Offline
Posts: 2
Quote kmckenzie Replybullet Posted: 01 Feb 2007 at 8:10am

Thanks for the help.  I will definitely be investing in your book soon.  I see how to pass the dataset over, but I guess my problem is with the creation of the report itself.  I and bind the viewer to the report and I can see my labels, but I see no data fields. 

This is how I handle my dataset creation and population:
Public Function EditPTORequestbyID(ByVal mID As Integer) As DataSet

Dim strSQL As String

strSQL = "SELECT * FROM tblPTORequest WHERE ID = " & mID

objDS = objData.RetrieveData(strSQL)

Me.shtCounter = 0

FillProperties()

Return objDS

End Function

Then I use the report code in the form Load event.
 
objDS = objPTO.EditPTORequestbyID(mintID)

FillTextBoxes()

Dim myReport As rptPTO = New rptPTO

myReport.Load("C:\ATLPTO\Atlanta PTO Request\Atlanta PTO Request\rptPTO.rpt")

myReport.SetDataSource(objDS)

CrystalReportViewer1.ReportSource = myReport

I appreciate the help and hate to be bothersome.
 
Ken Mckenzie


Edited by kmckenzie - 01 Feb 2007 at 8:14am
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 01 Feb 2007 at 11:12am
Hmmm... it looks pretty good to me. I'm a bit confused why you are instantiating the report object as rptPTO and then using the Load() method to pull it from the server. If you are using an embedded report, then all you need to do is instantiate the report object. If you aren't using an embedded report then you can just instantiate it with the ReportDocument class. But still, I don't think that is the cause of your problem - it's just something that looks odd.

When you call SetDataSource(), pass a second parameter using the table name. That can resolved problems sometimes.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.015 seconds.