cancel
Showing results for 
Search instead for 
Did you mean: 

Crystal Report Loading blank

Former Member
0 Kudos

Hi

Am using crystal report in visual studio 05.I have some prblm with it.I have created a dataset(.xsd file)and using it in report file.

but while loading the report it load as blank.sometimes it wil ask for login information.I have pasted the code below.

System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(ConfigurationManager.AppSettings["SqlConnectionString"]);

System.Data.SqlClient.SqlDataAdapter adpt = new System.Data.SqlClient.SqlDataAdapter("Select E.EmpName,n.NoOfLeaves from employeemaster e, leaveentry n where e.empid=n.empid and n.empid=2", conn);

DataSet dataSet = new DataSet();

adpt.Fill(dataSet);

ReportDocument mydoc = new ReportDocument();

string reportPath = Server.MapPath("CrystalReport.rpt");

mydoc.Load(reportPath);

for (int i = 0; i < mydoc.Database.Tables.Count; i++)

{

mydoc.Database.Tables<i>.SetDataSource(dataSet.Tables);

}

CrystalReportViewer1.ReportSource = mydoc;

PLease anyone help me.

Thanks in advance

Edited by: ZINKII on Apr 29, 2009 1:09 PM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

First make sure that you have not saved data with the report. Open the report and unchecked the small check box on the left top corner. Save it.

Make sure that dataset is not empty.

Try with this code sample which works for me:

OleDbConnection conn = new OleDbConnection("Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Password=sa;Initial Catalog=Northwind;Data Source=Server");
OleDbDataAdapter adpt=new OleDbDataAdapter("Select Orders.CustomerID,Orders.EmployeeId,Orders.OrderID,Orders.OrderDate,[order details].productid,[Order Details].UnitPrice,[Order Details].Quantity from [Order Details], Orders Where [Order Details].OrderID = Orders.OrderID",conn);
DataSet ds= new DataSet();
adpt.Fill(ds);
// USE THIS TO GET THE XML FILE TO CHECK FOR DATA AND Dataset SchemaContents
//ds.WriteXml("c:\\temp\\myData1.xml",XmlWriteMode.WriteSchema);
ReportDocument rd = new ReportDocument();
rd.Load("c:\\temp\\ADOReport.rpt");
rd.SetDataSource(ds);

CrystalReportViewer1.ReportSource=rd;

Helps?

Regards,

AG.

Answers (4)

Answers (4)

Former Member
0 Kudos

Closing post as no response for over 2 months.

Former Member
0 Kudos

hi

I have done as u said.the fields are coming correctly in xml.

but the report loads as same....with no data

thanks for ur quick responses

former_member183750
Active Contributor
0 Kudos

See if the [Troubleshooting Issues with VS .NET Datasets and Crystal Reports|https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/13270] [original link is broken] [original link is broken] [original link is broken]; blog provides more help.

Ludek

Former Member
0 Kudos

Hi

i opened the .rpt file but,

I coudnt find that mentioned checkbox.

Please specify clearly.

I tried in other way also but .the result was same

Former Member
0 Kudos

Hi,

Apologies! My mistake. This is not available with VS2005 embedded CR.

Did you use the xml file to see if the report is dropping any fields? for this open the report in design view, go to Crystal reports -> Database -> set datasource location. Create a new connection using ADO.Net and use the xml file. Update the fields and see if any table or filed is getting missed.

Regards,

AG.

Former Member
0 Kudos

Hi

Thanks for ur reply.

I have chkd with ur reply.

1) My dataset is filling correctly and i have not saved any data with report.

2)I coudnt find any checkbox as u mentioned.

Hoping ur help

Former Member
0 Kudos

Ok,

Another way:

Go to File. Un-check the "save data with report" option. Save the report.

Did you try the code? I have not used any loop to move through tables. Does it help?

Regards,

AG.