Crystal report with Serviced-based Database
I'm using an Service-based database (project mdf file) and the app is
working great. Now i need to create some reports using Crystal Report in
VS2008, but my reports keep comming up empty.
I've tried what i did using the access database and set the datasource to
the DataSet and also tried to the connection. inside the actual rpt i've
picked the project connection, but also tried every other way to connect to
the darn thing..
Either the report comes up empty or it does not show at all...
Could anybody help me, prefferrably with examples... I'm not all together
intimate with Crystal Reports, so i see myself as a newbie newbie in that
respect...
Re: Crystal report with Serviced-based Database
If you are using a datasource and dataset for the report then crystal report doesn't need to connect to the database. Just set the reports datasource to the dataset.
Post your code and maybe we can help find the problem.
Re: Crystal report with Serviced-based Database
i also try that one sir but no data has been display in my report, its just the field name ..
this is my code, hope you can help me solve this problem ..
vb Code:
Dim connectionstring As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=G:\Documents and Settings\MELVIN\Desktop\PayrollSystem\PayrollSystem\PayrollSystem.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
Dim sql As String = "SELECT * FROM SSSCHED"
sqlcon = New SqlConnection(connectionstring)
sqladap = New SqlDataAdapter(sql, sqlcon)
Dim ds As New DataSet
sqlcon.Open()
sqladap.Fill(ds, "SSSCHED")
sqlcon.Close()
DataGridView1.DataSource = ds
DataGridView1.DataMember = "SSSCHED"
mReport.Load("H:\Projects\CrystalReport\CrystalReport\CrystalReport1.rpt")
mReport.SetDataSource(ds)
CrystalReportViewer1.ReportSource = mReport
Re: Crystal report with Serviced-based Database
Does the information show in DataGridView1? Also, how did you design the report? How did you add the field objects to the report?
Re: Crystal report with Serviced-based Database
yup the data that should be in the report will appear in the datagridview so that i can check if the report is correct ..
i enter the crystal report design view to create the report and i just click some button there and add fields and the report viewer did the whole thing so i think its not the problem ..
i think the connection or datasource of the report has the problem ..
like how to set the datasource for the report and some syntax that will be use just for serviced-based database ..
and i don't have any idea about that .. xD
Re: Crystal report with Serviced-based Database
As I said in post #2, if your using a dataset as the reports datasource, then the database isn't an issue. As long as the data gets loaded into the dataset, the report will work. Your code loads the same data into a dgv and you say it show the correct data, so the dataset must contain the data you want.
Quote:
Either the report comes up empty or it does not show at all.
What exactly happens? If it is completely blank (no text like column or row headers) then there's a problem loading the report.
Code:
mReport.Load("H:\Projects\CrystalReport\CrystalReport\CrystalReport1.rpt")
Here's an example of how I do it,
Code:
Dim con As New OleDb.OleDbConnection(My.Settings.WaterConnectionString)
Dim ds As New WaterTablesDataSet
Dim da As New OleDb.OleDbDataAdapter("select userid,name from users", con)
da.Fill(ds.users)
Dim rpt As New CrystalReport2
rpt.SetDataSource(ds)
Dim frm As New frmReports
frm.CrystalReportViewer1.ReportSource = rpt
frm.Show()
CrystalReport2 is a Crystal report that I added to my project by "Project>Add new item>Crystal Report"
Re: Crystal report with Serviced-based Database
uhm i guess your right ..
but the report has a column and row header,date and page number on it
so i think that is not the problem at all ..
and thats why i'm really confused about it ..
i don't know whats the problem ..
by the way did you try it using sql code like mine ..
and what database did you use ..
try to make a crystal report using sql code and serviced-based database
and maybe you will find something .. thanks
Re: Crystal report with Serviced-based Database
try this and see if it shows an error,
Code:
Try
Dim connectionstring As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=G:\Documents and Settings\MELVIN\Desktop\PayrollSystem\PayrollSystem\PayrollSystem.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
Dim sql As String = "SELECT * FROM SSSCHED"
sqlcon = New SqlConnection(connectionstring)
sqladap = New SqlDataAdapter(sql, sqlcon)
Dim ds As New DataSet
sqlcon.Open()
sqladap.Fill(ds, "SSSCHED")
sqlcon.Close()
DataGridView1.DataSource = ds
DataGridView1.DataMember = "SSSCHED"
mReport.Load("H:\Projects\CrystalReport\CrystalReport\CrystalReport1.rpt")
mReport.SetDataSource(ds)
CrystalReportViewer1.ReportSource = mReport
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Re: Crystal report with Serviced-based Database
it works .. hehe ..
but i think the cause of the problem was the computer i been using all along ..
my computer doesn't have any anti-virus cause it shout down, i don't know why, and because of that i got plenty of virus and try to have a dual boot to run my program to another os .. and it works fine ..
i think the visual studio is had been corrupt so that the crystal report didn't function well .. thank you for your time and effort sir ..
sorry if it turn out to be my fault .. but thanks to you i know many thing in crystal report now ..
can i ask another question? .. xD
i using know the crystal report and it works perfectly fine ..
but want put my global variable in the crystal report
but i don't know how ..
do you have any idea about it ?..
thanks again .. take care ..
Re: Crystal report with Serviced-based Database
Quote:
but want put my global variable in the crystal report
I don't know what that means. You need to provide a detailed explanation of what your trying to accomplish.
Re: Crystal report with Serviced-based Database
sorry if i didn't explain it clearly ..
here what i want to do ..
i have a variable like name of person who wanted to print the report
and i want his/her name to be printed inside the crystal report ..
how can i put that variable to the textbox of the crystal report
so that every name i choose to put in that variable will appear in the
report ..
any idea .. thanks
Re: Crystal report with Serviced-based Database
Here's on way to manually put text in a textbox.
Code:
Dim rpt As New rptUsersAssessments
Dim objT As CrystalDecisions.CrystalReports.Engine.TextObject
objT = DirectCast(rpt.GroupHeaderSection1.ReportObjects("AssessMemo1"), CrystalDecisions.CrystalReports.Engine.TextObject)
objT.Text = "what ever text you want"
There are also special fields that you can put text in,
Code:
Dim rpt As New GroupsByUserId
rpt.SummaryInfo.ReportTitle = clsCoInfo.CompName & vbNewLine & clsCoInfo.Address1
rpt.SummaryInfo.ReportComments = "123 north street"
rpt.SummaryInfo.ReportAuthor = "report author"
Re: Crystal report with Serviced-based Database
i try the first code you post ..
i try to put it in the form load of may frmPreview
where the cystalreportviewer is located ..
but there was an error on, the rptUsersAssessments is not declare in my project.. i think i don't have its reference ..
can you give me a hint .. tsk tsk
Re: Crystal report with Serviced-based Database
That was just an example, rptUsersAssessments is the name of a CR report in my project. Use your report name, the correct report section name, and the correct reportObjects name.