on 04-29-2009 12:08 PM
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Closing post as no response for over 2 months.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.