|
-
Oct 26th, 2006, 08:13 PM
#1
Thread Starter
Frenzied Member
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
-
Oct 26th, 2006, 10:22 PM
#2
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
-
Oct 27th, 2006, 03:19 AM
#3
Thread Starter
Frenzied Member
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
-
Oct 27th, 2006, 03:29 AM
#4
Re: CR not display data in the report.
 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.
-
Oct 27th, 2006, 04:09 AM
#5
Thread Starter
Frenzied Member
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
-
Oct 27th, 2006, 04:53 AM
#6
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:
Dim CrystalReportViewer1 As CrystalDecisions.Windows.Forms.CrystalReportViewer = New CrystalDecisions.Windows.Forms.CrystalReportViewer
Dim Report As CrystalDecisions.CrystalReports.Engine.ReportDocument = New CrystalDecisions.CrystalReports.Engine.ReportDocument
CrystalReportViewer1.ActiveViewIndex = 0
CrystalReportViewer1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
CrystalReportViewer1.DisplayGroupTree = False
CrystalReportViewer1.Dock = System.Windows.Forms.DockStyle.Fill
CrystalReportViewer1.Location = New System.Drawing.Point(0, 0)
CrystalReportViewer1.Name = "CrystalReportViewer1"
Dim QueryString As String = "select * from TableName" 'Your Query here
Dim Connection As New OleDbConnection(funcs.con) 'Your Database Connection Here
Connection.Open()
Dim Adapter As OleDbDataAdapter = New OleDbDataAdapter(querystring, connection)'Passing the query in the connection
Dim DataSet As DataSet = New DataSet() 'DataSet
Adapter.Fill(DataSet)
Dim DataTable As DataTable = New DataTable 'DataTable
DataTable = DataSet.Tables(0) 'filling the datatable here
Report.Load(Application.StartupPath & "/ReportName.rpt") 'Report Name Here
Report.SetDataSource(DataTable)
CrystalReportViewer1.ReportSource = Report
Last edited by shakti5385; Oct 27th, 2006 at 04:56 AM.
Reason: Add VBCODE
-
Oct 27th, 2006, 05:25 AM
#7
Thread Starter
Frenzied Member
Re: CR not display data in the report.
Hello,
Thanks for the code, just a quick comment. Did you use typed dataset?
Thanks,
Steve
-
Oct 27th, 2006, 05:53 AM
#8
Thread Starter
Frenzied Member
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
-
Oct 27th, 2006, 05:54 AM
#9
Re: CR not display data in the report.
 Originally Posted by steve_rm
Hello,
Thanks for the code, just a quick comment. Did you use typed dataset?
Thanks,
Stee
Typed Data Set
-
Oct 27th, 2006, 07:01 AM
#10
Thread Starter
Frenzied Member
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
-
Oct 27th, 2006, 09:29 AM
#11
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
-
Oct 27th, 2006, 11:03 AM
#12
Thread Starter
Frenzied Member
Re: CR not display data in the report.
Thanks for answering my questions,
Steve
-
Oct 27th, 2006, 11:25 AM
#13
Re: CR not display data in the report.
 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|