Solved

CrystalDecisions.CrystalReports.Engine.LogOnException logon failed

Posted on 2004-08-21
13
596 Views
Last Modified: 2007-12-19
Hi every body..
I have created a report using ADO.NET XML (xml schema file) and in the webform I used the following procedure to log onto SQL Server database:
Private Sub LogonToReport _
   (ByRef Report As ReportDocument)
        Dim logonInfo As New TableLogOnInfo
        Dim table As Table

        ' Set the logon information for each table.
        For Each table In Report.Database.Tables
            logonInfo = table.LogOnInfo
            logonInfo.ConnectionInfo.ServerName = "xx"
            logonInfo.ConnectionInfo.DatabaseName = "xx"
            logonInfo.ConnectionInfo.UserID = "sa"
            logonInfo.ConnectionInfo.Password = "xx"
            ' Apply the connection information to the table.
            table.ApplyLogOnInfo(logonInfo)
        Next table
    End Sub
but I got the error "CrystalDecisions.CrystalReports.Engine.LogOnException logon failed"
Could any body help me PLZ.. Thanks in advance...
0
Comment
Question by:Hassan_Ghanem
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 3
  • +2
13 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 11864113
0
 
LVL 42

Expert Comment

by:frodoman
ID: 11864436
The link posted by mlmcc is probably the solution you need.  If not, please post the rest of the code you use to call the report.

frodoman
0
 
LVL 4

Author Comment

by:Hassan_Ghanem
ID: 11867390
I didn't include the table name when I filled the dataSet
MyDataAdapter.Fill(dataSet)
but my SQL statement which I used to fill my dataSet contains more than one table..how could I include them...
0
On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

 
LVL 42

Expert Comment

by:frodoman
ID: 11869058
I believe you just need to reference the primary table when you fill your dataset.

  MyDA.Fill(dataSet, "PrimaryTable")

That should be sufficient to meet Crystal's dereferencing needs.

frodoman
0
 
LVL 10

Expert Comment

by:ebolek
ID: 11869703
This is how I do it. Hoepfully it helps
Regards
Emre

public DataSet FillDataSet(DataSet MyDataSet)
            {
                  SqlConnection MyConnectionString = new SqlConnection("server=xx;database=xx;UID=xx;PWD=xx;");
                  string SQL;
                  SQL = "tablename";            
                 
                  //Create a DataAdapter, and then provide the name of the stored procedure.
                  SqlDataAdapter MyDataAdapter = new SqlDataAdapter(SQL, MyConnectionString);

                  //Set the command type as StoredProcedure.
                  MyDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure;

                  //Create and add a parameter to Parameters collection for the stored procedure.
                  MyDataAdapter.SelectCommand.Parameters.Add(new SqlParameter("@CaseID", SqlDbType.VarChar, 25));
                  MyDataAdapter.SelectCommand.Parameters.Add(new SqlParameter("@line_number", SqlDbType.Int));
                  MyDataAdapter.SelectCommand.Parameters.Add(new SqlParameter("@company_id", SqlDbType.VarChar, 4));
                  //Assign the search value to the parameter.
                  MyDataAdapter.SelectCommand.Parameters["@CaseID"].Value = _parametervalues[0];
                  MyDataAdapter.SelectCommand.Parameters["@line_number"].Value = _parametervalues[1];
                  MyDataAdapter.SelectCommand.Parameters["@company_id"].Value = _parametervalues[2];
                  MyDataAdapter.Fill(MyDataSet.Tables["tablename"]);
                  return MyDataSet;
            }

Regards
Emre
0
 
LVL 4

Author Comment

by:Hassan_Ghanem
ID: 11870376
frodoman what did u mean by Primay table? I have tried every table but it hasn't solve the problem..
0
 
LVL 10

Expert Comment

by:ebolek
ID: 11870405
did u try my code, If yes, you have to set all the tables connection information and parameter information. Dataset needs these information to fill it with data. The above code is written for only one table. But you can pass the table name and adjust the indexes of the parameter and load all the tables.
0
 
LVL 4

Author Comment

by:Hassan_Ghanem
ID: 11870768
ebolek.. I have done that but the problem hasn't been solved.
0
 
LVL 42

Expert Comment

by:frodoman
ID: 11870785
Can you post your code for us to look at?
0
 
LVL 10

Expert Comment

by:ebolek
ID: 11871594
what error message does it give. I know that my code works because i set it for my reports. But i have one stored proc in my dataset. why dont you do different datasets for each table. Then it will definitely work or adjust the code above to set miltiple tables from it

Regards
Emre
0
 
LVL 1

Accepted Solution

by:
M0m0nga earned 250 total points
ID: 11876269
Everybody else seems to like the "extended version" of Log on code. Why not do this:

myReportDocument.SetDatabaseLogon("username", "password")

if you have subreports you might need to do it for those too eg:

myReportDocument.OpenSubreport("mySubReport1").SetDatabaseLogon("username", "password")
myReportDocument.OpenSubreport("mySubReport2").SetDatabaseLogon("username", "password")

Note also that logon error message isn't always about the logon as such. I've had this problem a few times and sometimes the actual cause is something almost totally unrelated.
 
0
 
LVL 4

Author Comment

by:Hassan_Ghanem
ID: 11878139
M0m0nga ... I couldn't locate setDataBaseLogon method...
the following is my code.. by the way it works on my computer even without the logon procedure but the logon error appears when I install my application on the production environment..

Dim connectionString As String = "server='xxx'; user id='xx'; password='xx'; database='xxxxx'"
        Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionString)
        Dim queryString As String = "SELECT     Expenses.ReceiptNo, Expenses.ReceiptDate,   Expenses.CheckNO, ExpensesDetails.beneficiaryName, ExpensesDetails.ItemAmount, ExpensesDetails.Description, " & _
            "AccountCode.Description AS mAcct, AccountCode_1.Description AS subAcct " & _
            "FROM         ExpensesDetails ExpensesDetails INNER JOIN " & _
            "AccountCode AccountCode_1 ON ExpensesDetails.CodeID = AccountCode_1.ID INNER JOIN " & _
            "Expenses Expenses ON ExpensesDetails.ExpenseID = Expenses.ID INNER JOIN " & _
            "AccountCode AccountCode ON AccountCode_1.MajorID = AccountCode.ID "

 Dim dbCommand As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
        dbCommand.Connection = dbConnection

        Dim dataAdapter As System.Data.SqlClient.SqlDataAdapter = New System.Data.SqlClient.SqlDataAdapter
        dataAdapter.SelectCommand = dbCommand
        Dim dataSet As System.Data.DataSet = New System.Data.DataSet
        dataAdapter.Fill(dataSet)

0
 
LVL 4

Author Comment

by:Hassan_Ghanem
ID: 11880373
Thanks M0m0nga..  Thanks all...
I have downloaded Crystal Reports .Net 1.1 Service Pack 2 and used setdatabaselogon method..
it solved my problem...

Hassan Ghanem....
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question