Results 1 to 14 of 14

Thread: Crystal Report DataSource

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2006
    Posts
    910

    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)

  2. #2
    Hyperactive Member
    Join Date
    Jul 2007
    Posts
    479

    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.

  3. #3
    Hyperactive Member r0k3t's Avatar
    Join Date
    Dec 2005
    Location
    Cleveland
    Posts
    361

    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.
    Anti DUPLO machine!!!

  4. #4
    Hyperactive Member r0k3t's Avatar
    Join Date
    Dec 2005
    Location
    Cleveland
    Posts
    361

    Re: Crystal Report DataSource

    Oh - Don't forget to rate my post if it is good
    Anti DUPLO machine!!!

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2006
    Posts
    910

    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

    Quote 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.

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2006
    Posts
    910

    Re: Crystal Report DataSource

    rasinc, I don't see either of these options.

    Quote 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.

  7. #7
    Hyperactive Member
    Join Date
    Jul 2007
    Posts
    479

    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.

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2006
    Posts
    910

    Re: Crystal Report DataSource

    Any more suggestions!?!?!?

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2006
    Posts
    910

    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?

  10. #10

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2006
    Posts
    910

    Re: Crystal Report DataSource

    Bump!

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2006
    Posts
    910

    Re: Crystal Report DataSource

    This problem is a big problem for me. Can anyone help? Or have I stumped the whole VBForums community??

  12. #12
    Frenzied Member
    Join Date
    May 2006
    Location
    some place in the cloud
    Posts
    1,886

    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

  13. #13

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2006
    Posts
    910

    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!

  14. #14

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2006
    Posts
    910

    Re: Crystal Report DataSource

    Anyone?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width