|
-
Aug 21st, 2008, 12:46 PM
#1
Thread Starter
Fanatic Member
Crystal Report DataSource
Does anyone see why the report in this code would use the datasource that was used when it was created instead of the dataset that it is told to use?
Code:
Dim da As New OleDbDataAdapter("SELECT tblAbsenteeism.AssociateID, tblAbsenteeism.AssociatesName, tblAbsenteeism.DepartmentName, tblAbsenteeism.ReasonCode, tblAbsenteeism.OccurrenceDate, tblAbsenteeism.Points, tblAssociateInformationList.Active FROM tblAbsenteeism INNER JOIN tblAssociateInformationList ON tblAbsenteeism.AssociateID = tblAssociateInformationList.AssociateID WHERE tblAssociateInformationList.Active = ?", cn)
Dim ds As New DataSet
da.SelectCommand.Parameters.Add("@Active", OleDbType.Boolean).Value = True
da.FillSchema(ds, SchemaType.Source, "tblAbsenteeism")
da.Fill(ds)
Dim cr As New AbsDaysPerDeptGreaterThanSix
cr.SetDataSource(ds.Tables("tblAbsenteeism"))
CrystalReportViewer1.ReportSource = cr
(Rate)
-
Aug 22nd, 2008, 09:13 PM
#2
Hyperactive Member
Re: Crystal Report DataSource
I am not quite up on .NET code so I am going to tackle it from a Crystal point of view. Whenever, I see reports that show original data, I check to make sure the Save Data with Report option is turned off in the design or I insert the DiscardSavedData command when running it. This option is turned on in some versions of Crystal by default.
Hope this helps.
-
Aug 25th, 2008, 08:06 AM
#3
Hyperactive Member
Re: Crystal Report DataSource
jre1229
How did you define the fields? If you went into the database expert and created a database connection and then dragged the fields onto the report it will always grab data from the database - I don't understand the internals of Cystal Reports so I don't why this is or if you can stop it.
I recently got stuck creating some reports and this is what I figured out (mind you I am a web/c# guy).
I created a new dataset by adding a new item to my project. Then in the dataset designer (will pop up and ask automatically) you create the data elements you want, then save it.
I then create a class that matches that same dataset. I.E. If I created a dataset that has three elements lets say for example,
string model
string make
int modeYear
I create a class that has those same three items.
Now that I have my class and my dataset, I go back to crystal reports and use the "database expert" to add my dataset - this will be under ADO.NET datasets. The sweet thing is all you have to do it drag the fields on the report and format them, no formulas, nothing! that is all done in the background
Now - In you code, you create an arraylist, then create as many objects as you please. stick each on into the arraylist and then set the datsource to the arraylist, I am not sure what the magic is but if the objects in the arraylist match the datset then they show up in the report.
Agian, I don't know if this is the best way to go about this or not. Maybe there is a better way. This is just what I figured out after being thrown to the wolves so to speak...
Hopefully that is helpful.
-
Aug 25th, 2008, 08:07 AM
#4
Hyperactive Member
Re: Crystal Report DataSource
Oh - Don't forget to rate my post if it is good
-
Aug 26th, 2008, 01:28 PM
#5
Thread Starter
Fanatic Member
Re: Crystal Report DataSource
r0k3t,
This is not true as all of my reports have been created by using the database expert and dragging the fields onto my report. And I have been able to simply have it use a dataset at runtime to make it work. The only time I run into a problem is when I use multiple tables. If it works with one table then it should work with multiple tables, I just don't know how. Not saying your way will not work but I always create my dataset at runtime and I never use arrays so your method would be very troublesome for me. Plus, it should work this way, someone has to know what I am doing wrong.... I just have to find that someone
 Originally Posted by r0k3t
jre1229
How did you define the fields? If you went into the database expert and created a database connection and then dragged the fields onto the report it will always grab data from the database - I don't understand the internals of Cystal Reports so I don't why this is or if you can stop it.
-
Aug 27th, 2008, 07:16 AM
#6
Thread Starter
Fanatic Member
Re: Crystal Report DataSource
rasinc, I don't see either of these options.
 Originally Posted by rasinc
I am not quite up on .NET code so I am going to tackle it from a Crystal point of view. Whenever, I see reports that show original data, I check to make sure the Save Data with Report option is turned off in the design or I insert the DiscardSavedData command when running it. This option is turned on in some versions of Crystal by default.
Hope this helps.
-
Aug 29th, 2008, 04:58 PM
#7
Hyperactive Member
Re: Crystal Report DataSource
Sorry I am not sure what would be used in .NET because I use VB6, the Crystal OCX and usually the actual Crysal Designer to create the reports.
For working in the RDC in VB6 you can use
Report.DiscardSavedData
But I am not sure how to translate it to what you are doing.
-
Sep 5th, 2008, 03:20 PM
#8
Thread Starter
Fanatic Member
Re: Crystal Report DataSource
Any more suggestions!?!?!?
-
Sep 22nd, 2008, 07:19 AM
#9
Thread Starter
Fanatic Member
Re: Crystal Report DataSource
I am still having this problem. How does everyone else file a crystal report from a typed dataset with multiple tables?
-
Oct 1st, 2008, 07:05 AM
#10
Thread Starter
Fanatic Member
Re: Crystal Report DataSource
-
Jan 16th, 2009, 03:53 PM
#11
Thread Starter
Fanatic Member
Re: Crystal Report DataSource
This problem is a big problem for me. Can anyone help? Or have I stumped the whole VBForums community??
-
Jan 16th, 2009, 07:33 PM
#12
Re: Crystal Report DataSource
In VS2005, the SetDataSource() method of a CrystalReport has four
override functions.
They are :
SetDataSource(DataSet),
SetDataSource(DataTable),
SetDataSource(IDataReader) and
SetDataSource(IEnumerable).
If you pass a strong-typed DataTable to the SetDataSource() method like the following:
oRpt.SetDataSource(Me.myDataSet.myDataTable), the VS2005 compiler consider this call ambiguous between the SetDataSource(DataTable) method and the SetDataSource(IEnumerable) method.
To fix the problem, you should cast the datatable instance to DataTable type.
The following is a sample.
oRpt.SetDataSource((DataTable)Me.myDataSet.myDataTable);
Found in : dev newsgroups
-
Feb 12th, 2009, 10:07 AM
#13
Thread Starter
Fanatic Member
Re: Crystal Report DataSource
jggtz,
Thanks for the reply as I am still having this problem. But I don't believe I understand. What is the (DataTable) in oRpt.SetDataSource((DataTable)Me.myDataSet.myDataTable)? Do I need to create a datatable from my dataset first? See my code in post #1, this is what I am working with.
Thanks!
-
Mar 6th, 2009, 07:49 AM
#14
Thread Starter
Fanatic Member
Re: Crystal Report DataSource
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|