Click here to Skip to main content
16,011,805 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The project contains two tables 1) PatientTB & 2) ListTB,
PatientTB contains all patient details, and ListTB consist of item that patient's purchase.
now the column Patient_Id is an primary key in PatientTB and same column is an foreign key to ListTB table.
when I create a crystal report with anyone of above table it works fine.
but when I select both the tables no data will display.

if I select PatientTB or ListTB from dataset crystal report will work fine.
but selection of both tables can not display anything because of relationship of primary-foreign key in both the tables.

my query is :

con.Open();
cmd = new SqlCommand("SELECT Date,Doctor,Patient.Patient_Id,Patient_Name,Contact_No,Payment_Type,Item_Count,Grand_Total,List.Batch_No,List.Item_Code,List.Item_Name,List.Exp_Date,List.Qwantity,List.MRP,List.Amount FROM Patient INNER JOIN List ON Patient.Patient_Id = List.Patient_Id WHERE Patient.Patient_Id = '" + Main.txt_crs_pid.Text + "'", con);
SqlDataReader sdr = cmd.ExecuteReader();
DataTable dt = new DataTable();
dt.Load(sdr);
CrystalSale report = new CrystalSale();
report.SetDataSource(dt);
crystalReportViewer1.ReportSource = report;
con.Close();

Thanking you in advance.
Posted
Updated 24-Oct-16 7:44am

Dear sir,
in vb.net
I want to print report from one table
like this
My origional table

SR Year Amount
1 2009 1000
2 2008 2000
3 2009 4500
4. 2008 1000

I want to print it like

SR 2008 2009
1 3000 5500

Number of Years are fixed

Please help

Mangesh Rajput
 
Share this answer
 
Comments
[no name] 24-Oct-16 14:11pm    
Please do not post questions as answers to other questions. And you would have to be a lot more descriptive about what you problem is.
If u r using Multiple Table means u should use separate table datasource to view the crystal report

In your code

report.SetDataSource(dt);

change to

C#
report1.Database.Tables[0].SetDataSource(dd.Tables[0]);
report1.Database.Tables[1].SetDataSource(dd1.Tables[0]);


if u are using 2 means u should call 2 datasource for crystal report
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900