Solved

Login Failed when there are 2 connections in SubReports - even when applying table wise correct connection info

Posted on 2004-08-03
7
326 Views
Last Modified: 2008-01-09
Hi Expert,

I have created a Report with a Sub report and both have 2 connection information. Viz. Main Report has 2 connections - 1
Connection to data source using Stored Procedure (SQL Server) and second connection to data source which provides fields
based upon Language selected say English, Spanish etc. so we have one separate Language Database. Similar is the case with
Sub Report. Now when I am passing the connection info as shown below in Steps to reproduce, then 1st page gets displayed
perfectly but clicking on the second page gives the Login Failed Error, but if I have only 1 connection in both main
Report and sub report the same code works fine. Is there any resolution to this???
 
CODE ----------------------------------------------------------------------------------
 
Page_Init()
 
Code-------------------------------------
If TypeOf Session.Item("CESession") Is Object Then
                ceSession = Session.Item("CESession")
            Else
                If LoginCrystalEnterprise(ConfigurationSettings.AppSettings("Username"), ConfigurationSettings.AppSettings("Password"), ConfigurationSettings.AppSettings("CmsServer"), ConfigurationSettings.AppSettings("AuthenticationType")) Then
                    ceSession = Session.Item("CESession")
                End If
            End If
 
            reportDoc.EnterpriseSession = ceSession
            reportDoc.FileName = ConfigurationSettings.AppSettings("Uri") & GetReportId(reportSource, reportDoc.EnterpriseLogonInfo.Username, reportDoc.EnterpriseLogonInfo.Password, reportDoc.EnterpriseLogonInfo.CmsServer, reportDoc.EnterpriseLogonInfo.AuthenticationType)
 
            Call CreateParameterFieldsDirect(returnParameters, reportDoc)
 
            For Each objSection In reportDoc.ReportDefinition.Sections
                For Each objReportObject In objSection.ReportObjects
                    If objReportObject.Kind = ReportObjectKind.SubreportObject Then
                        Dim objDatabaseSubreport As CrystalDecisions.CrystalReports.Engine.Database
                        Dim objTablesSubreport As CrystalDecisions.CrystalReports.Engine.Tables
                        Dim objTableLogonInfoSubreport As CrystalDecisions.Shared.TableLogOnInfo
                        Dim objTableSubreport As CrystalDecisions.CrystalReports.Engine.Table
                        Dim objCrystalConnectionInfoSubreport As CrystalConnectionInformation
 
                        Try
                            objSubReportObject = CType(objReportObject, SubreportObject)
                            subreportDoc = objSubReportObject.OpenSubreport(objSubReportObject.SubreportName)
                            objDatabaseSubreport = subreportDoc.Database
                            objTablesSubreport = objDatabaseSubreport.Tables
                            For Each objTableSubreport In objTablesSubreport
                                objTableLogonInfoSubreport = objTableSubreport.LogOnInfo
                                objCrystalConnectionInfoSubreport = objHashTable.Item(objTableSubreport.Name.ToLower)
                                Dim objConnectionInfoSubreport As New CrystalDecisions.Shared.ConnectionInfo
                                objConnectionInfoSubreport.ServerName = objCrystalConnectionInfoSubreport.ServerName
                                objConnectionInfoSubreport.UserID = objCrystalConnectionInfoSubreport.UserId
                                objConnectionInfoSubreport.DatabaseName = objCrystalConnectionInfoSubreport.DatabaseName
                                objConnectionInfoSubreport.Password = objCrystalConnectionInfoSubreport.Password
                                objTableLogonInfoSubreport.ConnectionInfo = objConnectionInfoSubreport
                                System.Threading.Thread.CurrentThread.Sleep(waitTime)
                                objTableSubreport.ApplyLogOnInfo(objTableLogonInfoSubreport)
                                System.Threading.Thread.CurrentThread.Sleep(waitTime)
                                'intCounter = 0
                                'objTableSubreport.ApplyLogOnInfo(objTableLogonInfoSubreport)
                                'System.Threading.Thread.CurrentThread.Sleep(waitTime)
                                'While (Not objTableSubreport.TestConnectivity()) And (intCounter < ConfigurationSettings.AppSettings("maxConnectionCounter"))
                                'System.Threading.Thread.CurrentThread.Sleep(waitTime)
                                'intCounter += 1
                                'End While
 
                                If Not objTableSubreport.TestConnectivity() Then
                                    Throw New ApplicationException("Unable to Connect Table:" & objTableSubreport.Name & " Connection Info:" & objConnectionInfoSubreport.ServerName)
                                End If
                            Next
                        Finally
                            objDatabaseSubreport = Nothing
                            objTablesSubreport = Nothing
                            objTableLogonInfoSubreport = Nothing
                            objTableSubreport = Nothing
                            objCrystalConnectionInfoSubreport = Nothing
                        End Try
                    End If
                Next
            Next
 
            objDatabase = reportDoc.Database
            objTables = objDatabase.Tables
 
            For Each objTable In objTables
                objTableLogonInfo = objTable.LogOnInfo
                objCrystalConnectionInfo = objHashTable.Item(objTable.Name.ToLower)
                Dim objConnectionInfo As New CrystalDecisions.Shared.ConnectionInfo
                objConnectionInfo.ServerName = objCrystalConnectionInfo.ServerName
                objConnectionInfo.UserID = objCrystalConnectionInfo.UserId
                objConnectionInfo.DatabaseName = objCrystalConnectionInfo.DatabaseName
                objConnectionInfo.Password = objCrystalConnectionInfo.Password
                objTableLogonInfo.ConnectionInfo = objConnectionInfo
                System.Threading.Thread.CurrentThread.Sleep(waitTime)
                objTable.ApplyLogOnInfo(objTableLogonInfo)
                System.Threading.Thread.CurrentThread.Sleep(waitTime)
                intCounter = 0
                'objTable.ApplyLogOnInfo(objTableLogonInfo)
                'System.Threading.Thread.CurrentThread.Sleep(waitTime)
                'While (Not objTable.TestConnectivity()) And (intCounter < ConfigurationSettings.AppSettings("maxConnectionCounter"))
                'System.Threading.Thread.CurrentThread.Sleep(waitTime)
                'intCounter += 1
                'End While
 
                If Not objTable.TestConnectivity() Then
                    Throw New ApplicationException("Unable to Connect Table:" & objTable.Name & " Connection Info:" & objConnectionInfo.ServerName)
                End If
            Next
 
crystalReportViewer.DataBind()
 

 

ERROR-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Server Error in '/Reports' Application.
--------------------------------------------------------------------------------
 
Logon failed. Details: 28000:[Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'demodb_cds'. Error in File C:\WINDOWS\TEMP\{6384703C-1EDA-4AA8-95CF-84C30EB995E8}.rpt: Unable to connect: incorrect log on parameters.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
 
Exception Details: System.Runtime.InteropServices.COMException: Logon failed. Details: 28000:[Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'demodb_cds'. Error in File C:\WINDOWS\TEMP\{6384703C-1EDA-4AA8-95CF-84C30EB995E8}.rpt: Unable to connect: incorrect log on parameters.
 
Source Error:
 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  
 
Stack Trace:
 
 
[COMException (0x8004100f): Logon failed.
Details: 28000:[Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'demodb_cds'.
Error in File C:\WINDOWS\TEMP\{6384703C-1EDA-4AA8-95CF-84C30EB995E8}.rpt:
Unable to connect: incorrect log on parameters.]
   CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass.GetPage(PageRequestContext pPageRequestContext) +0
   CrystalDecisions.ReportSource.EromReportSourceBase.GetPage(PageRequestContext pageReqContext)
 
[LogOnException: Logon failed.
Details: 28000:[Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'demodb_cds'.
Error in File C:\WINDOWS\TEMP\{6384703C-1EDA-4AA8-95CF-84C30EB995E8}.rpt:
Unable to connect: incorrect log on parameters.]
   CrystalDecisions.ReportAppServer.ConvertDotNetToErom.ThrowDotNetException(Exception e)
   CrystalDecisions.ReportSource.EromReportSourceBase.GetPage(PageRequestContext pageReqContext)
   CrystalDecisions.CrystalReports.Engine.FormatEngine.GetPage(PageRequestContext reqContext)
   CrystalDecisions.ReportSource.LocalReportSourceBase.GetPage(PageRequestContext pageReqContext)
   CrystalDecisions.Web.ReportAgent.&#8209;(Boolean i)
   CrystalDecisions.Web.CrystalReportViewer.OnPreRender(EventArgs e)
   System.Web.UI.Control.PreRenderRecursiveInternal()
   System.Web.UI.Control.PreRenderRecursiveInternal()
   System.Web.UI.Control.PreRenderRecursiveInternal()
   System.Web.UI.Page.ProcessRequestMain()
 
Best Regards;
Ashish
0
Comment
Question by:medirta
  • 2
  • 2
7 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 11703351
What version of Crystal.  Version before CR9 did not like multiple sources for the data thus the need for subreports.  CR9 supposedly allows multiple ources but only if they are the same database type.  It may be that a stored proecedure and your othewr connection are viewed as different types.

Does the report run from the Crystal designer?

mlmcc
0
 
LVL 42

Expert Comment

by:frodoman
ID: 11703771
I agree with mlmcc and I can confirm from my own experience that CR9 doesn't like combination of SP and db table even if they're on the same database.  

I suggest that you either modify the SP to return the information from the ancillary table as well as the data currently being sent back or have your main report connect only to the SP and make a subreport to connect only to the table.

frodoman
0
 

Author Comment

by:medirta
ID: 11747405
Hi Frodoman and Mlmcc,

I am using CR10.

Further to make it more clearer,

Eg. 1. Crystal report without sub report :

1 connection to DB1 and another connection to DB2 - working perfectly both in Designer and Viewer.

Eg. 2. Crystal report with sub report :

Main Report - Connection to DB1
Sub report - Connection to DB2

Working perfectly in Designer....but causing problems in Viewer (.NET), also first page works perfectly 7/10 times, while clicking 2nd page give me the Login fail error.

Thanks for help....waiting for reply.

Regards
Ashish
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 63 total points
ID: 11749444
0
 
LVL 42

Assisted Solution

by:frodoman
frodoman earned 62 total points
ID: 11751920
It looks like you're using multithreading in your application.  Have you verified that the database drivers you're using are thread safe?  If not that would explain the intermittent errors.

I don't have CR10 but I know in CR9 the ODBC drivers were thread-safe only for SQL Server and Sybase.  Most but not all native drivers are thread-safe.  You can probably check your CR help for a list of them - I found it in CR9 help searching for "thread-safe".

HTH

frodoman
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

830 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