Crystal Report ask Logon information for Simple Dataset. How to hide it?
I know that there are some threads have a similar issue with this thread. But, I couldn't find one which solve my problem.
I use Visual Studio 2010 and I create a dataset with one table. I want to show the data in the Crystal Report Viewer. But when it begins to load, it asks me login information. I don't set anything about login information on my dataset. That's why I'm confused.
This is my code for adding a dummy row in the table:
dataSet = new DummyDS(); dummyTable = dataSet.Tables["Simulation"]; // fill table with random data Object dummyObj = new Object; dummyObj = null; dummyObj = 1; dummyObj = 2; dummyTable.Rows.Add(dummyObj);
This is my code for loading the crystal report viewer:
CrystalReport1 cr = new CrystalReport1(); cr.Load(); crystalReportViewer1.ReportSource = cr; crystalReportViewer1.Refresh();
I want to show my data in Crystal Report Viewer without being asked for logon information. Could you help me to solve this problem? Thank you in advance.
upgraded to answer status as I assume it was the answer:
You need to set the report data source to the data set you have created. If you dont set the data source for the report to the dataset then you are relying on CR just guessing which dataset to use!
From my experience : The Logon window could appear in these cases :
- Database connection string not provided (to do that Use CrystalReport1.SetDatabaseLogon("UserID", "Password", "Server", "DatabaseName"))
- The query contains nonexisting objects.
- Some other cases that I haven't met yet.
I have the same problem sometimes but unfortunately it does not have anything to do with any login process (as you suspected). When CR fails to create a report, on some occasions the error being thrown will be something like:
"Load report failed (Logon failed)"
which has nothing to do with the login itself. Even if you do not use authentication at all, it might very well give you this error. I suggest exporting the report to disk, for example using ExportToDisk with the PDF option. This will probably also generate an error but you can catch it easily and it might give you more information.
In any case, I think the error lies in the report generation itself (not authentication), for example in record selection formulae, formatting formulae or in a group function. Or some other mismatch between the schema CR expects and the actual data you are providing.
The dummy data you are creating and putting in the report, does it have the exact same schema as the one you built the CR file with?