Not able to display data in crystal report. I am using Blank crystal report. I have executed a Join Query and Datatable is returned perfectly. Getting error while execution "The report has no tables" at cr.SetDataSource(dt) in below code.
DataTable dt = new DataTable();
dt = db.GetClientStatus(clientID);
CrystalReport1 cr = new CrystalReport1();
cr.SetDataSource(dt);
crystalReportViewer1.ReportSource = cr;
void BindReport() {
SqlClient.SqlConnection myConnection = new SqlClient.SqlConnection();
myConnection.ConnectionString = "server= (local)\\NetSDK;database=pubs;Trusted_Connection=yes";
SqlClient.SqlCommand MyCommand = new SqlClient.SqlCommand();
MyCommand.Connection = myConnection;
MyCommand.CommandText = "Select * from Stores";
MyCommand.CommandType = CommandType.Text;
SqlClient.SqlDataAdapter MyDA = new SqlClient.SqlDataAdapter();
MyDA.SelectCommand = MyCommand;
Dataset1 myDS = new Dataset1();
// This is our DataSet created at Design Time
MyDA.Fill(myDS, "Stores");
// You have to use the same name as that of your Dataset that you created during design time
CrystalReport1 oRpt = new CrystalReport1();
// This is the Crystal Report file created at Design Time
oRpt.SetDataSource(myDS);
// Set the SetDataSource property of the Report to the Dataset
CrystalReportViewer1.ReportSource = oRpt;
// Set the Crystal Report Viewer's property to the oRpt Report object that we created
}
OK I am explaining it. db is the object of a custom class dealing with database let say DataBaseMethods. It is having multiple methods like for insert, update, delete for type of queries.
DataBaseMethods db = new DataBaseMethods();
With db I am calling one of the method which is returning Datatable. I am passing ClientID which is GUID types and used to get data from the table via Where clause like
Member
23 Points
124 Posts
The report has no tables - Crystal Report
Jun 04, 2012 11:56 AM|hallojatin|LINK
Not able to display data in crystal report. I am using Blank crystal report. I have executed a Join Query and Datatable is returned perfectly. Getting error while execution "The report has no tables" at cr.SetDataSource(dt) in below code.
Please help me on this.
Thanks,
Jatin
Contributor
5972 Points
1481 Posts
Re: The report has no tables - Crystal Report
Jun 04, 2012 12:13 PM|MahadTECH|LINK
Jatin Good day~
Try these links these are your Answers..
good luck`
MCP, MCSD
For .NET TECH Blog
Member
23 Points
124 Posts
Re: The report has no tables - Crystal Report
Jun 04, 2012 12:26 PM|hallojatin|LINK
Hi,
Can you please let me know that where I am wrong in my code?
Thanks,
Jatin
Contributor
5972 Points
1481 Posts
Re: The report has no tables - Crystal Report
Jun 04, 2012 12:33 PM|MahadTECH|LINK
you just wrote 5lines of your Code. In Which I dont know .db and ClientID and Full scenario..So, Try
From This Link : http://www.beansoftware.com/ASP.NET-Tutorials/Using-Crystal-Reports.aspx
This is an Example Try
MCP, MCSD
For .NET TECH Blog
Member
23 Points
124 Posts
Re: The report has no tables - Crystal Report
Jun 04, 2012 12:46 PM|hallojatin|LINK
Hi,
OK I am explaining it. db is the object of a custom class dealing with database let say DataBaseMethods. It is having multiple methods like for insert, update, delete for type of queries.
DataBaseMethods db = new DataBaseMethods();
With db I am calling one of the method which is returning Datatable. I am passing ClientID which is GUID types and used to get data from the table via Where clause like
select something from table1 where table1.ClientID=@ClientID.
the method which I am calling is
For handling data I am using LINQ to SQL.
I dont know that if the Datatable returned by the above method works fine, so why
cr.SetDataSource(dt); giving error in my code as mentioned in my first post.
Thanks,
Jatin
Contributor
6711 Points
2334 Posts
Re: The report has no tables - Crystal Report
Jun 11, 2012 02:23 AM|cnranasinghe|LINK
Did you desing the report schema first? Report need design time fields to display records.
check follwing
http://www.codeproject.com/Articles/142064/Step-by-Step-Creation-of-Crystal-Report-using-its