Last post Mar 17, 2011 06:53 AM by vineetrok
Mar 15, 2011 09:37 AM|vineetrok|LINK
I have database with 5 tables as follows
in my crystal report I am trying to display the patient details of only one patient (whose pid is requested by the user) and display the tests information of that patient.
I have created a dataset and have the following code in codebehind of crystalreportviewer
Protected Sub btngenerate_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btngenerate.Click
Dim enteredpid As String = txtname.Text
Dim pid As Integer = enteredpid
Dim myConnection As New SqlClient.SqlConnection()
myConnection.ConnectionString = "Data Source=ADMIN-PC\VINSERVER;Initial Catalog=NewPro_db;Integrated Security=True"
Dim MyCommand As New SqlClient.SqlCommand("patientpid", myConnection)
MyCommand.CommandType = CommandType.StoredProcedure
MyCommand.Parameters("@pid").Value = pid
Dim MyDA As New SqlClient.SqlDataAdapter()
MyDA.SelectCommand = MyCommand
Dim myDS As New test()
Dim oRpt As New Patientreports()
CrystalReportViewer1.ReportSource = oRpt
I also have a stored procedure to check the whether the pid entered is same as the pid in the test reports tables
somewhat like follows
ALTER PROCEDURE dbo.testresults
if exists(select * from bloodinfo where Pid = @pid)
select patientdetails.pname, etc. etc.....
from patientdetails, bloodinfo where bloodinfo.pid=patientdetails.pid
and patientdetails.pid = @pid
/*repeated above condition for remaining tests also*/
but still It is not displaying anything in the crystalreport.
please help me out!
Mar 16, 2011 07:59 AM|sirdneo|LINK
As per your ERD, data should be availble in all child tables, even if any of the child table do not contain data, then no data will be displayed in your report.
Mar 16, 2011 08:15 AM|vineetrok|LINK
No, if I use that stored procedure only the first if statement is executed and remaining are not, thus, only data from patientdetails table are stored in dataset.
maximum I can store data from two tables using the query in the dataset, but moment I include 3rd table everything falls apart.
please help, just want to get my stored procedure right.
Mar 17, 2011 12:22 AM|sirdneo|LINK
You have to create sub reports to display this kind of data. In your main report only add the parent table. then create three sub reports for each table.
Mar 17, 2011 02:20 AM|vineetrok|LINK
I have 4 stored procedures which get data from the four tables of the database based on the pid entered by the user.
I have created 4 datasets and used them in each of the 4 subreports.
how do I modify the following code to display these four subreports in the crystalReportViewer??
Mar 17, 2011 03:16 AM|sirdneo|LINK
Yes you have to set datasource for individual subreport as well like this:-
above code is in C# i think in VB it will be like this:-
Sory for syntax if it is wrong in VB
Mar 17, 2011 06:53 AM|vineetrok|LINK
thank you for answering, but I got it solved without using subreports, rather using stored procedure like
yes, above syntax is correct.