Link to home
Start Free TrialLog in
Avatar of Anvie
Anvie

asked on

Remove Crystal Report LogOn The report you requested requires further information

Hi,

I ' am creating reports using crystal report included in visual studio 2005. I successfully can pass parameter programmically but every time I run the crystal report I receive this message:

The report you requested requires further information

Then ask me to enter the MS SQL 2005 Login password.

I would like remove that page and go directly to the report. In my connection string I declared the password. I dont know why it is still asking me to enter password again.

Please help me ;-(

Thanks!
Avatar of Wikkard
Wikkard
Flag of Australia image

Ahh the perenial crystal logon issue. If I had a dollar for everytime I've encountered this!

The problem is that crystal caches the login info you used when you designed the report. So you need to loop over the tables collection and set the logon for each table in the report.

I've attached some code which has successfully worked for me in the past.

  ConnectionInfo connectionInfo = new ConnectionInfo(); //our connection details
 
            try
            {
 
                connectionInfo.DatabaseName = System.Configuration.ConfigurationManager.AppSettings["DataBaseName"].ToString(); // cms database change to production
                string username = Session["strUserCMSName"].ToString();//cms username 
                connectionInfo.UserID = username;
                connectionInfo.Type = ConnectionInfoType.CRQE; //SQL;//sql server 
 
                string password = Session["strUserPassword"].ToString();//cms password
                connectionInfo.Password = password;
                connectionInfo.ServerName = System.Configuration.ConfigurationManager.AppSettings["DataBaseServer"].ToString(); //changing to our production database server
            }
            catch (Exception ex) 
            {
                lblerror.Text = ex.ToString();
                return; 
            } 
 
 
 
  private void SetDBLogonForReport(ConnectionInfo connectionInfo, ReportDocument reportDocument)
        {
            //loop over each table in the reports and set the logon/connection info
            Tables tables = reportDocument.Database.Tables;
            foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
            {
                TableLogOnInfo tableLogonInfo = table.LogOnInfo;
                tableLogonInfo.ConnectionInfo = connectionInfo;
                table.ApplyLogOnInfo(tableLogonInfo);
                table.Location = "dbo." + table.Location;//this line is crutial for some sql configs - you may or not need it
            }
        }

Open in new window

You also need to make sure that the server you deploy this to has the crystal reports runtimes installed. You can do that by creating an empty setup package and adding the crystalreports merge module into it. (or by installing visual studio on the server ;p)

I'll see if I can convert this code to vb for you also....give me a couple of hours and I'll get back to you.

Private Sub SetDBLogonForReport(ByVal connectionInfo As ConnectionInfo, ByVal reportDocument As ReportDocument)
    'loop over each table in the reports and set the logon/connection info
    Dim tables As Tables = reportDocument.Database.Tables
    For Each table As CrystalDecisions.CrystalReports.Engine.Table In tables
        Dim tableLogonInfo As TableLogOnInfo = table.LogOnInfo
        tableLogonInfo.ConnectionInfo = connectionInfo
        table.ApplyLogOnInfo(tableLogonInfo)
            'this line is crutial depending on how your sql server is configured        table.Location = "dbo." + table.Location
    Next
End Sub
Avatar of Anvie
Anvie

ASKER

Hi I recieve this error:

Type 'CrystalDecisions.Web.CrystalReportSource' in Assembly 'CrystalDecisions.Web, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' is not marked as serializable.
Avatar of Anvie

ASKER

I don't know if I did it right, this is my code:


Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared


Partial Class _Default
    Inherits System.Web.UI.Page
    Public ReportDocument As New ReportDocument()

    Protected Sub CrystalReportViewer1_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles CrystalReportViewer1.Init


        Dim connectionInfo As New ConnectionInfo()

        'loop over each table in the reports and set the logon/connection info
        Dim Tables As Tables = ReportDocument.Database.Tables


        For Each table As CrystalDecisions.CrystalReports.Engine.Table In Tables
            Dim tableLogonInfo As TableLogOnInfo = table.LogOnInfo
            tableLogonInfo.ConnectionInfo = connectionInfo
            table.ApplyLogOnInfo(tableLogonInfo)
            'this line is crutial depending on how your sql server is configured        
            table.Location = "ETC." + table.Location
        Next
    End Sub


Thanks!



   
End Class
Avatar of Anvie

ASKER

I tried different code but I still get the same error:



Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
 
 
Partial Class _Default
    Inherits System.Web.UI.Page
    Public ReportDocument As New ReportDocument()
 
    Protected Sub CrystalReportViewer1_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles CrystalReportViewer1.Init
 
        Dim pServerName As String
        Dim pDbName As String
        Dim pUserid As String
        Dim pPwd As String
 
        pServerName = "ETC01"
        pDbName = "Matrix"
        pUserid = "trinity"
        pPwd = "trinity"
 
 
 
        Dim crTable As Table
        Dim crTables As Tables
 
        Dim crTabLogonInfo As TableLogOnInfo
 
        '/*** Information provider for connection with the Database ***/
        Dim crConnectionInfo As New ConnectionInfo()
 
        Dim intCnt As Integer
 
        crConnectionInfo.ServerName = pServerName
        crConnectionInfo.DatabaseName = pDbName
        crConnectionInfo.UserID = pUserid
        crConnectionInfo.Password = pPwd
 
        '/*** To get the Database object ***/
        crTables = ReportDocument.Database.Tables
 
 
        For intCnt = 0 To crTables.Count - 1
            crTable = crTables.Item(intCnt)
            crTabLogonInfo = crTable.LogOnInfo
            crTabLogonInfo.ConnectionInfo = crConnectionInfo
            crTable.ApplyLogOnInfo(crTabLogonInfo)
        Next
    End Sub
 
   
End Class

Open in new window

You need to load the reportDocument and specify the ConnectionInfo values.
ie

ReportDocument reportDocument = new ReportDocument()'//new report            reportDocument.Load(reportPath)'//load the report .rpt file
connectionInfo.DatabaseName = "myDatabase"
connectionInfo.UserID = "myUsername"
connectionInfo.Type = ConnectionInfoType.CRQE '//SQL Server
connectionInfo.Password = "myPassword"
connectionInfo.ServerName = "localhost\SQLEXPRESS" ' the sql server


Also I'm not sure if you should be initialising the report inside the viewer_init event. Try moving it to page_load.


You definitely have the crystal runtimes installed on your webserver ?
There should be folders under C:\Program Files\Common Files\Business Objects\2.7 with the crystal runtime files.
Avatar of Anvie

ASKER

yes I do:

I change the code and now I recive different error:

Exception Details: System.Runtime.InteropServices.COMException: The system cannot find the file specified

I check the path of my CR and it is correct.

Thanks!

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
 
 
Partial Class _Default
    Inherits System.Web.UI.Page
    Public ReportDocument As New ReportDocument()
 
    Protected Sub CrystalReportViewer1_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles CrystalReportViewer1.Init
 
        Dim pServerName As String
        Dim pDbName As String
        Dim pUserid As String
        Dim pPwd As String
 
        pServerName = "ETC01"
        pDbName = "Matrix"
        pUserid = "trinity"
        pPwd = "trinity"
 
 
 
        Dim crTable As Table
        Dim crTables As Tables
 
        Dim crTabLogonInfo As TableLogOnInfo
 
        '/*** Information provider for connection with the Database ***/
        Dim crConnectionInfo As New ConnectionInfo()
 
        Dim intCnt As Integer
 
        crConnectionInfo.ServerName = pServerName
        crConnectionInfo.DatabaseName = pDbName
        crConnectionInfo.UserID = pUserid
        crConnectionInfo.Password = pPwd
 
        '/*** To get the Database object ***/
        Dim Filepath As String
        Filepath = Server.MapPath("./Report\TransactionDetails.rpt")
        ReportDocument.Load(Filepath, OpenReportMethod.OpenReportByDefault)
        crTables = ReportDocument.Database.Tables
 
        For intCnt = 0 To crTables.Count - 1
            crTable = crTables.Item(intCnt)
            crTabLogonInfo = crTable.LogOnInfo
            crTabLogonInfo.ConnectionInfo = crConnectionInfo
            crTable.ApplyLogOnInfo(crTabLogonInfo)
        Next
    End Sub
 
   
End Class

Open in new window

My first thought is that is would be an issue with the report path.
I tried this code and it worked ok.

    Protected Sub CrystalReportViewer1_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles CrystalReportViewer1.Init
 
        Dim pServerName As String
        Dim pDbName As String
        Dim pUserid As String
        Dim pPwd As String
 
        pServerName = "localhost\SQLEXPRESS"
        pDbName = "database"
        pUserid = "username"
        pPwd = "password"
 
 
 
        Dim crTable As Table
        Dim crTables As Tables
 
        Dim crTabLogonInfo As TableLogOnInfo
 
        '/*** Information provider for connection with the Database ***/
        Dim crConnectionInfo As New ConnectionInfo()
 
        Dim intCnt As Integer
 
        crConnectionInfo.ServerName = pServerName
        crConnectionInfo.DatabaseName = pDbName
        crConnectionInfo.UserID = pUserid
        crConnectionInfo.Password = pPwd
 
        '/*** To get the Database object ***/
        Dim Filepath As String
        Filepath = Server.MapPath("dummy.rpt")
        ReportDocument = New ReportDocument()
        ReportDocument.Load(Filepath, OpenReportMethod.OpenReportByDefault)
        crTables = ReportDocument.Database.Tables
 
        For intCnt = 0 To crTables.Count - 1
            crTable = crTables.Item(intCnt)
            crTabLogonInfo = crTable.LogOnInfo
            crTabLogonInfo.ConnectionInfo = crConnectionInfo
            crTable.ApplyLogOnInfo(crTabLogonInfo)
        Next
 
 
        CrystalReportViewer1.ReportSource = ReportDocument
 
    End Sub

Open in new window

Avatar of Anvie

ASKER

Hello, yes the code above works but I am back to my original problem, it ask for password to run the report ;-( please help...
Avatar of Anvie

ASKER

any update on this please
Avatar of Anvie

ASKER

Is it posible you send me the actual app that already working? Please... I have deadline for this ;-(

Thank you!
Avatar of Mike McCracken
What didn't work about the code?

Does the report show?

Does the report have a subreport?

mlmcc
Avatar of Anvie

ASKER

The report shows but it ask me for the database password and I dont want that.

I really appriciate your help on this.

Thanks
Are you passing the correct password?

mlmcc
Here is the full codebehind file that I was using.

Ensure that your reportViewerControl has disable logon prompt set to false.
ie.
        <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true"
            EnableDatabaseLogonPrompt="False" HasRefreshButton="True" />

The code below picks up the username etc from the web.config file.  
If you still can't get it working I would check your password etc.
Imports CrystalDecisions.Web
Imports CrystalDecisions.ReportSource
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System.Web
 
 
 
Partial Class DefaultPage
    Inherits System.Web.UI.Page
    Public ReportDocument As ReportDocument
    Public ReportTitle As String
    Public ReportFilename As String
 
 
    Protected Sub InitReport()
        Dim pServerName As String
        Dim pDbName As String
        Dim pUserid As String
        Dim pPwd As String
 
        pServerName = System.Configuration.ConfigurationManager.AppSettings("server")
        pDbName = System.Configuration.ConfigurationManager.AppSettings("database")
        pUserid = System.Configuration.ConfigurationManager.AppSettings("username")
        pPwd = System.Configuration.ConfigurationManager.AppSettings("password")
 
 
 
        Dim crTable As Table
        Dim crTables As Tables
 
        Dim crTabLogonInfo As TableLogOnInfo
 
        '/*** Information provider for connection with the Database ***/
        Dim crConnectionInfo As New ConnectionInfo()
 
        Dim intCnt As Integer
 
        crConnectionInfo.ServerName = pServerName
        crConnectionInfo.DatabaseName = pDbName
        crConnectionInfo.UserID = pUserid
        crConnectionInfo.Password = pPwd
 
        '/*** To get the Database object ***/
        Dim Filepath As String
        Filepath = Server.MapPath("dummy.rpt")
        ReportDocument = New ReportDocument()
        ReportDocument.Load(Filepath, OpenReportMethod.OpenReportByDefault)
        crTables = ReportDocument.Database.Tables
 
        For intCnt = 0 To crTables.Count - 1
            crTable = crTables.Item(intCnt)
            crTabLogonInfo = crTable.LogOnInfo
            crTabLogonInfo.ConnectionInfo = crConnectionInfo
            crTable.ApplyLogOnInfo(crTabLogonInfo)
        Next
 
        CrystalReportViewer1.ReportSource = ReportDocument
    End Sub
 
    Protected Sub CrystalReportViewer1_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles CrystalReportViewer1.Init
        InitReport()
    End Sub
 
   
End Class

Open in new window

Avatar of Anvie

ASKER

Hi, I recieved a logIn failed msg. I check my database connection and I am 100% it is correct. Please help me out. Thanks!

Below is my web.config file. I am newbie in this, I am sorry for the trouble.
<?xml version="1.0"?>
<!-- 
 
-->
<configuration>
  
  <configSections>
    <sectionGroup name="businessObjects">
      <sectionGroup name="crystalReports">
        <section name="reportMappings" type="CrystalDecisions.Shared.ReportMappingHandler, CrystalDecisions.Shared, Version=12.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304, Custom=null"/>
      </sectionGroup>
    </sectionGroup>
  </configSections>
  
  <system.web>
    <compilation debug="true" strict="false" explicit="true">
      
      <buildProviders>
        <add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.Common, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
      </buildProviders>
      
      <assemblies>
        <add assembly="CrystalDecisions.CrystalReports.Engine, Version=12.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
        <add assembly="CrystalDecisions.Enterprise.Framework, Version=12.0.1100.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
        <add assembly="CrystalDecisions.ReportAppServer.ClientDoc, Version=12.0.1100.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
        <add assembly="CrystalDecisions.Shared, Version=12.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
        <add assembly="CrystalDecisions.Enterprise.InfoStore, Version=12.0.1100.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
        <add assembly="CrystalDecisions.Web, Version=12.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
        <add assembly="CrystalDecisions.Enterprise.Desktop.Report, Version=12.0.1100.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
        <add assembly="CrystalDecisions.ReportSource, Version=12.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
      </assemblies>
      
    </compilation>
    
    <pages>
      <namespaces>
        <clear/>
        <add namespace="System"/>
        <add namespace="System.Collections"/>
        <add namespace="System.Collections.Specialized"/>
        <add namespace="System.Configuration"/>
        <add namespace="System.Text"/>
        <add namespace="System.Text.RegularExpressions"/>
        <add namespace="System.Web"/>
        <add namespace="System.Web.Caching"/>
        <add namespace="System.Web.SessionState"/>
        <add namespace="System.Web.Security"/>
        <add namespace="System.Web.Profile"/>
        <add namespace="System.Web.UI"/>
        <add namespace="System.Web.UI.WebControls"/>
        <add namespace="System.Web.UI.WebControls.WebParts"/>
        <add namespace="System.Web.UI.HtmlControls"/>
      </namespaces>
    </pages>
 
    <authentication mode="Windows"/>
 
    <httpHandlers>
      <add path="CrystalImageHandler.aspx" verb="GET" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=12.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
      <add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" validate="false"/>
    </httpHandlers>
  </system.web>
  
  
  
  
  <location allowOverride="true">
    <appSettings>
      <add key="CrystalImageCleaner-AutoStart" value="true" />
      <add key="CrystalImageCleaner-Sleep" value="60000" />
      <add key="CrystalImageCleaner-Age" value="120000" />
 
      <add key="Connection" value="server=ETC01;database=Matrix;uid=Trinity;pwd=trinity;pooling=false"/>
      <add key="server" value="ETC01"/>
      <add key="DataBase" value="Matrix"/>
      <add key="username" value="Trinity"/>
      <add key="Password" value="trinity"/>
 
    </appSettings>
  </location>
  <system.webServer>
    <handlers>
      <add name="CrystalImageHandler.aspx_GET" verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=12.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" preCondition="integratedMode"/>
    </handlers>
    <validation validateIntegratedModeConfiguration="false"/>
  </system.webServer>
  <businessObjects>
    <crystalReports>
      <reportMappings>
        <add reportName="TransactionDetails.rpt" path="TransactionDetails.rpt"/>
      </reportMappings>
    </crystalReports>
  </businessObjects>
</configuration>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Wikkard
Wikkard
Flag of Australia image

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 Anvie

ASKER

Yes I did changed 'enable login prompting' property on the report viewer control. I recieved a LogIn error.

I also tried to change my DB connection to OLEDB Provider for SQL Server but I still have the same error.

Please suggest me something what to do with this. I already created several reports in CR and I dont want to create it again in different tool because of this.

Thanks,
Hi Anvie,
Did u get any Solution for this problem yet? i am facing the same problem. i am using it in Windows forms though.
While debugging, i found that the password is not set sometimes for the ConnectionIfo.password propert of some tables. this happens randomly. moreover, the CrystalReportDocument's DataSourceConnections[0].Password .propert is set to the assigned password just while setting the logon info for the first table, and while setting the logon info for the remaining table, this property of CrystalReportDocument.DataSourceConnections[0].Password  is lost. may be this is the reason that it prompts for the passsword/ Login Information during Runtime.
My problem is that i have to change the Database server during the runtime.
Moreover, as mentioned above, i am not able to see "Enable Login Prompting" propert for the ReportViewer Object, i am using CrystalReportViewer object in Windows Forms

 for Cryatal report's Data source   give table instead of data set it works.

Example:

rptObjEMPReport.SetDataSource(dsEMPReport.Tables["procEMPReport1"]);