Link to home
Start Free TrialLog in
Avatar of malparam
malparam

asked on

CrystalDecisions.CrystalReports.Engine.LogOnException: Logon failed.

I tried to put the 4 lines of code, in code behind page i get errors in the code.
crystalreport1 orpt = new crystalreport1()
orpt.setdatabaselogon("user","password")
crystalreportviewer1.reportsource = orpt
crystalreportviewer1.databind()

It does not accept the first two lines. I get an error. There is no setdatabaselogon
method with orpt.
I am trying to create a report using crystalreportviewer. I get this logon failure.
Please help me.
ASKER CERTIFIED SOLUTION
Avatar of Cheeetaa
Cheeetaa

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rolftollerud
rolftollerud

Let's take it from the beginning.

1) Make a new webproject (ASP.NET Web Application) in Visual studio.
2) Press left mousebutton at projectname in Solution Explorer and click
Add Reference, CrystalDecisions.Web, click Select, and close with the OK
button.
3) Press again left mousebutton at projectname, this time choose Add/Add
New Item/Crystal Report. When the Crystal report Gallery comes up choose
"Using the Report Expert"
4) Use the wizard to create your report (CrystalReport1.rpt.)
5) Go to your first page (WebForm1.aspx). From toolbox/webforms find the
component CrystalReportViewer (you may have to scroll) and drag it to the
main window.

6) in the codebehind you put(C#):

crystalreport1 orpt = new crystalreport1()
orpt.setdatabaselogon("user","password")
crystalreportviewer1.reportsource = orpt
crystalreportviewer1.databind()

If you use vb:

Dim oRpt As CrystalReport1
oRpt = New CrystalReport1()
orpt.setdatabaselogon "user","password"
CrystalReportViewer1.ReportSource = oRpt
CrystalReportViewer1.DataBind()

(crystalreport1 is the name of your report, if you named it something
else, change the code). Change "user" and "password" to the real user and
password.

save and run




Remember that Upper and Lowercase is important. If your report is named CrystalReport1 then your code must be CrystalReport1orpt = new CrystalReport1(). Likewise with CrystalReportViewer1.
Just ask again if you need to. I assure you that the report runs perfectly on my computer.
Avatar of malparam

ASKER

Dim oRpt As CrystalReport1
        oRpt = New CrystalReport1()
        oRpt.setdatabaselogon("user", "password")
        CrystalReportViewer1.ReportSource = oRpt
        CrystalReportViewer1.DataBind()
THis is what I have. It is underlining oRpt.setdatabaselogon. It is not allowing me to use that.When I type a . after oRpt it only gives datasource. There is no databaselogon. Please help me.
the line
oRpt.setdatabaselogon("user", "password")

should be oRpt.setdatabaselogon "user", "password"

without the "(     )"

but this line is not absolutely necessary, try to comment it out.
(you gave the servername, database, user and password when you created the report!)
Malini!
How is it going?
I still get logon failure. I commented the orpt.setdatabase line.I canot use setdatabaselogon with orpt. It gives me a an error. By the way this is webform.
It is not a windows application. the windows application works fine.
I do not have to set any logon info in code behind. But I am trying to create a web application. It is not allowing me to do this. Please help!
I had only tried with the C# version before. Now I have tried with vb , and that also runs correct.

So the reason must lie in the way you make your report. You says "I do not have to set any logon info in code behind". You does not have to as you set that information in the Report Wizard.

The Standard Report Expert Wizard have 8 tabs.
Data, Fields, Group, Total, Top N, Chart, Select, Style

In the first tab "Data", when you select OLE DB (ADO) data source you are presented witha a dialog of OLE DB Providers. Choose "Microsoft OLE DB Provider for SQL Server" and click next.

Then you are asked for the connection parameters, In Server: you type the name of your server, in User ID: your userid, Password: your password, and Database: your database. Click finish.

THen while you still are at the data tab in the Wizard, choose a table from the database.

Click next to get to the tab "Fields".
Choose a couple of fields.

Click finish. Now you have your report CrystalReport1.rpt

Can you conform that you have a virtuel directory CrystalReportWebFormViewer pointing to
C:\Program Files\Microsoft Visual Studio .NET 2003\Crystal Reports\Viewers\?
isolved this problem using datasets and putting the connection info in the program.
thanks
malini
the setdatabaselogon method does not solve the problem for me. Also, that method does require the "( )" around the arguments

The problem seems to be related to Crystal Reports not saving the the password when specifying the connection for the report. I deduced this from the fact that if i reset the sa password pon sql server to blank it works fine.

Does anyone have any ideas as to how to fix such a problem?
You may find if using Crystal Reports in Visual Studio 2002 that you have to install the Crystal Reports Service Patch to get extra functionality like this. I think the file is called crnet10win_en.zip. It added the .SetParameterValue() function to VS2002 so maybe this is the reason your version of VS doesnt have .SetDatabaseLogon().

Just a thought for others reading this.
The problem is corrected when applying the patch,
thanks