Results 1 to 13 of 13

Thread: CR not display data in the report. [ resolved ]

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    CR not display data in the report. [ resolved ]

    Hello,

    I am using VS 2005 and CR 10. I have using typed dataset. However, I have a problem displaying the data in the report. I have created an typed dataset.xsd called DS_JobSheet.xsd. I have previewed the data and it displays everything. I have created the reports.

    In the report I have select database expert / project Data / ADO.Net Dataset. I have select my dataset and selected the table.

    I have dragged the fields on to the report. I think everything seems to be ok here.

    The code for filling the report is below. I have added a grid to the report to see if that gets filled and it does. I just don't understand why my report does not show any data.

    I have imported
    CrystalDecisions.CrystalReports.Engine
    CrystalDecisions.Shared
    Can any correct if I have done something wrong.

    Many thanks,

    Steve

    Code:
    Private Sub frmJobSheet1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim customerReport As New rptJobSheet1()
            Dim DS_JobSheet As DataSet 'DS_JobSheet is the .xsd data schema, data has been generated
            Dim IDNumber As Integer
            Dim cnn As New SqlConnection()
            Dim da As New SqlDataAdapter()
            Dim cmd As New SqlCommand()
    
            cnn.ConnectionString = "server=steve02\ssd02; database=serviceMaster; pwd=a123; user id=sa"
    
            cmd.CommandType = CommandType.Text
            cmd.CommandText = "SELECT * FROM Incident"
            DS_JobSheet = New DataSet
    
            Try
                cnn.Open()
                cmd.Connection = cnn
    
                da.SelectCommand = cmd
                da.Fill(DS_JobSheet)
    
            Catch ex As Exception
                MessageBox.Show(ex.Message)
            End Try
    
            IDNumber = 68 'Display record for ID number 68 this number exists in the database table
    
            customerReport.SetDataSource(DS_JobSheet)
    
    
            Me.CrystalReportViewer1.Refresh()
            Me.CrystalReportViewer1.SelectionFormula = "{Incident.IncidentID} = " & IDNumber & " "
            Me.CrystalReportViewer1.ReportSource = customerReport 'Application.StartupPath & "\JobSheetReport\rptJobSheet1.rpt"
    
    
            Me.UltraGrid1.DataSource = DS_JobSheet.Tables(0).DefaultView 'Data is displayed in the datagrid so this is ok
            Me.UltraGrid1.Refresh()
    
            Me.CrystalReportViewer1.Show()
    
        End Sub
    Last edited by steve_rm; Oct 27th, 2006 at 11:18 AM.
    steve

  2. #2
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Re: CR not display data in the report.


    Check the crystal report if there is save data with report opetion is ture the unchacked it

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    Re: CR not display data in the report.

    Hello Shakti,

    I am using CR 10. I can't find this save data report option. I have looked under the properties of the report. Am I looking in the correct place for this. There is only about 10 properties. Is is something that would be in the field explorer?

    Thanks,

    Steve
    steve

  4. #4
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Thumbs up Re: CR not display data in the report.

    Quote Originally Posted by steve_rm
    Hello Shakti,
    I am using CR 10. I can't find this save data report option. I have looked
    Thanks,
    Steve
    This option will display at the file menu of the crystal report.
    Check it if it is checked the remove this check using the click on it.

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    Re: CR not display data in the report.

    I check the CR file menu.

    I could not see anything that refered to save data. Should CR 10 have this on the file menu?

    My friend has a simpliar problem as me, he can not get his report to display data using the typed dataset.

    The datagrid fills with data, so there is not a problem there in filling the dataset.

    I have removed this line:
    Me.CrystalReportViewer1.SelectionFormula = "{Incident.IncidentID} = " & IDNumber & " "
    So that i can display all the data.

    I have added this line:
    customerReport.Database.Tables(0).SetDataSource(DS_JobSheet2)

    But still the same problem.

    Thanks if you can help,

    Steve
    steve

  6. #6
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Thumbs up Re: CR not display data in the report.


    Hi
    I Make a simple code for printing data in the crystal report just read each and every line in the code and check it.
    Remember This code simply on the Form Load event.
    Test this code
    It is working fine at my PC.
    If you do not want to use the sql query then you can use the selection formulas also



    VB Code:
    1. Dim CrystalReportViewer1 As CrystalDecisions.Windows.Forms.CrystalReportViewer = New CrystalDecisions.Windows.Forms.CrystalReportViewer
    2.         Dim Report As CrystalDecisions.CrystalReports.Engine.ReportDocument = New CrystalDecisions.CrystalReports.Engine.ReportDocument
    3.         CrystalReportViewer1.ActiveViewIndex = 0
    4.         CrystalReportViewer1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
    5.         CrystalReportViewer1.DisplayGroupTree = False
    6.         CrystalReportViewer1.Dock = System.Windows.Forms.DockStyle.Fill
    7.         CrystalReportViewer1.Location = New System.Drawing.Point(0, 0)
    8.         CrystalReportViewer1.Name = "CrystalReportViewer1"
    9.  
    10.         Dim QueryString As String = "select * from TableName" 'Your Query here
    11.         Dim Connection As New OleDbConnection(funcs.con) 'Your Database Connection Here
    12.         Connection.Open()
    13.  
    14.         Dim Adapter As OleDbDataAdapter = New OleDbDataAdapter(querystring, connection)'Passing the query in the connection
    15.         Dim DataSet As DataSet = New DataSet() 'DataSet
    16.         Adapter.Fill(DataSet)
    17.         Dim DataTable As DataTable = New DataTable 'DataTable
    18.         DataTable = DataSet.Tables(0) 'filling the datatable here
    19.         Report.Load(Application.StartupPath & "/ReportName.rpt") 'Report Name Here
    20.         Report.SetDataSource(DataTable)
    21.         CrystalReportViewer1.ReportSource = Report
    Last edited by shakti5385; Oct 27th, 2006 at 04:56 AM. Reason: Add VBCODE

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    Re: CR not display data in the report.

    Hello,

    Thanks for the code, just a quick comment. Did you use typed dataset?

    Thanks,

    Steve
    steve

  8. #8

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    Re: CR not display data in the report.

    Thanks for your help. The report worked.

    You really are an expert.

    Now all l have to do is make this things fail so l know why it was not working for me.

    Just a quick question.
    why create a new report document
    Dim customerReport As New CrystalDecisions.CrystalReports.Engine.ReportDocument

    I was doing this:
    Dim customerReport As New rptJobSheet1() 'Is this wrong

    Me.CrystalReportViewer1.Name = "CrystalReportViewer1" 'Why this line

    Why do we need to do this, and have the report in the same folder as the exe
    report.Load(Application.StartupPath & "/rptJobSheet2.rpt")

    Thanks for your answers.

    Steve
    steve

  9. #9
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Thumbs up Re: CR not display data in the report.

    Quote Originally Posted by steve_rm
    Hello,
    Thanks for the code, just a quick comment. Did you use typed dataset?
    Thanks,
    Stee
    Typed Data Set

  10. #10

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    Re: CR not display data in the report.

    Hello,

    I did send you a post with some questions.

    Please if you have time can you answer them.

    Many thanks for your help today.

    Steve
    steve

  11. #11
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Thumbs up Re: CR not display data in the report.

    Thanks for your help. The report worked.
    You really are an expert.
    Your Welcome
    Not so much expert still learning


    Dim customerReport As New CrystalDecisions.CrystalReports.Engine.ReportDocument
    In a declaration or assignment statement, a New clause must specify a defined class from which the instance can be created. This means the class must expose a constructor that the calling code can access
    I was doing this:
    Dim customerReport As New rptJobSheet1() 'Is this wrong
    Can not say but remember you are using VS.NET so does not work here like Vb

    Why do we need to do this, and have the report in the same folder as the exe
    report.Load(Application.StartupPath & "/rptJobSheet2.rpt")
    This is the better way to work

    Hope Now you get all the answer

  12. #12

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    Re: CR not display data in the report.

    Thanks for answering my questions,

    Steve
    steve

  13. #13
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Thumbs up Re: CR not display data in the report.

    Quote Originally Posted by steve_rm
    Thanks for answering my questions,

    Steve

    If you got the solution of your question then go to the thread tool menu and click on the resloved this thread.

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