Crystal Report showing static login dialog

I created a crystal report using crystal report 11 and sql 2005. when i try to run the report from application , if the database  which is used to create the report not available in server or in local host it shows the login dialog. i checked the overridden name of the report. any help will be appreciated. Thanks in advance
err-screen-shot.JPG
pandianfswwincAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

wykabryanCommented:
Are you using BOE XIR1-2 or just Crystal?  If you are using BOE then you also need to populate the database tab within the CMC with the correct database information. Then uncheck the check box below that states to prompt user for username and password.
0
mlmccCommented:
Are you changing the datasource in the application?

If so what code are you using?

Does the report have a subreport?

mlmcc
0
pandianfswwincAuthor Commented:
No mlcc i dont change datasource in the application. and the report has no sub report. code used are given below



Dim intIC As Integer
    Dim strDataObject As String
    Dim strParVal As String = ""
    Dim strDataRange() As String
    Dim oDataRow As SqlClient.SqlDataReader
    Dim paramvalue As New ParameterDiscreteValue
    Dim Currentvalue As ParameterValues
 
    Try
 
      objfrmReportViewer = New frmReportViewer
 
      objfrmReportViewer.crptViewer.ReportSource = Application.StartupPath + "\Reports\" + strDataObject
      Dim str As String = Application.StartupPath + "\Reports\" + strDataObject
 
      Try
        RptDoc = New ReportDocument()
        'RptDoc.Load(Application.StartupPath + "\Reports\" + strDataObject, OpenReportMethod.OpenReportByDefault)
        RptDoc.Load(str)
 
      Catch ex As Exception
        MsgBox("Report file not found in " + Application.StartupPath + "\Reports\" + vbCrLf + ex.Message)
        Exit Sub
      End Try
 
      For intIndex = 0 To lsbParameterList.Items.Count - 1
        strParamField(intIndex) = New ParameterField
        strParamValue(intIndex) = New ParameterDiscreteValue
        strParamRangeValue(intIndex) = New ParameterRangeValue
 
        strParVal = ""
        Try
          If Not dtPicker1(intIndex) Is Nothing Then
            strParVal += dtPicker1(intIndex).SelectionRange.Start.Date.ToString()
            My.Settings.Item("DateRange1") = dtPicker1(intIndex).SelectionRange.Start.Date '.SelectionRange.Start.Date
 
          End If
          If Not dtPicker2(intIndex) Is Nothing Then
            strParVal += ";" + dtPicker2(intIndex).SelectionRange.Start.Date.ToString()
 
            My.Settings.Item("DateRange2") = dtPicker2(intIndex).SelectionRange.Start.Date
          End If
          If Not chklsbbox(intIndex) Is Nothing Then
            If chkbox(intIndex).Checked = False Then
              For intIC = 0 To chklsbbox(intIndex).Items.Count - 1
                If (chklsbbox(intIndex).GetItemCheckState(intIC) = CheckState.Checked) Then
                  strParVal += chklsbbox(intIndex).Items(intIC).ToString() + ";"
                End If
              Next intIC
              strParVal = strParVal.Substring(0, (strParVal.Length() - 1))
            Else
              strParVal = "All"
            End If
 
          End If
          If Not cmbbox1(intIndex) Is Nothing Then
            strParVal += cmbbox1(intIndex).SelectedValue.ToString()
          End If
          If Not cmbbox2(intIndex) Is Nothing Then
            strParVal += ";" + cmbbox2(intIndex).SelectedValue.ToString()
          End If
          If Not txtbox1(intIndex) Is Nothing Then
            strParVal = txtbox1(intIndex).Text.Trim()
          End If
          If Not mtxtbox1(intIndex) Is Nothing Then
            strParVal = mtxtbox1(intIndex).Text.Trim()
          End If
        Catch strNullExp As NullReferenceException
 
        Catch strExp As Exception
        Finally
        End Try
 
        crParameterFieldDefinitions(intIndex) = RptDoc.DataDefinition.ParameterFields
        crParameterFieldLocation(intIndex) = crParameterFieldDefinitions(intIndex).Item(intIndex)
        strParamField(intIndex).ParameterFieldName = crParameterFieldLocation(intIndex).ParameterFieldName
 
        If crParameterFieldLocation(intIndex).DiscreteOrRangeKind = DiscreteOrRangeKind.RangeValue Then
          strDataRange = strParVal.Split(";")
          strParamRangeValue(intIndex).StartValue = strDataRange(0)
          strParamRangeValue(intIndex).EndValue = strDataRange(1)
          strParamField(intIndex).CurrentValues.Add(strParamRangeValue(intIndex))
        ElseIf crParameterFieldLocation(intIndex).DiscreteOrRangeKind = DiscreteOrRangeKind.DiscreteValue Then
          If Not crParameterFieldLocation(intIndex).ParameterType = ParameterType.StoreProcedureParameter Then
            strDataRange = strParVal.Split(";")
            If (strDataRange.Length > 0) Then
              For intIC = 0 To strDataRange.Length - 1
                strParamValue(intIndex) = New ParameterDiscreteValue
                strParamValue(intIndex).Value = strDataRange(intIC)
                strParamField(intIndex).CurrentValues.Add(strParamValue(intIndex))
              Next intIC
            Else
              strParamValue(intIndex).Value = strParVal
              strParamField(intIndex).CurrentValues.Add(strParamValue(intIndex))
            End If
          Else
            strParamValue(intIndex).Value = strParVal
            strParamField(intIndex).CurrentValues.Add(strParamValue(intIndex))
          End If
        End If
        objfrmReportViewer.crptViewer.ParameterFieldInfo.Add(strParamField(intIndex))
 
        crParameterFieldLocation(intIndex).CurrentValues.Clear()
        paramvalue.Value = strParamValue(intIndex).Value
        Currentvalue = crParameterFieldLocation(intIndex).CurrentValues
        Currentvalue.Add(paramvalue)
        RptDoc.DataDefinition.ParameterFields(intIndex).ApplyCurrentValues(Currentvalue)
 
      Next intIndex
    Catch ex As Exception
      'MsgBox("Please enter all parameters")
      'Exit Sub
      MsgBox(ex.Message.ToString)
    End Try
 
    If btnRunReport.Text = "Print" Then
      ' This will Print Directely to the Printer
      SetLogOnInfo()
      printReport()
    ElseIf btnRunReport.Text = "Preview" Then
      ' This will Preview the report in the viewer
      SetLogOnInfo()
 
      objfrmReportViewer.Show()
    End If
  End Sub
 
  Public Sub SetLogOnInfo()
    'since using a Non-Typed report, and loading a report outside of the project, 
    'use the following Code:
    'Dim crtableLogonInfos As New TableLogOnInfos()
    Dim crTableLogonInfo As New TableLogOnInfo()
    Dim crConnectionInfo As New ConnectionInfo()
    Dim CrTables As Tables
    Dim CrSubrptTables As Tables
    Dim CrTable As Table
    Dim CrSubrptTable As Table
 
    Dim subRptDoc As New ReportDocument()
    Dim crSections As Sections
    Dim crSection As Section
    Dim crReportObjects As ReportObjects
    Dim crReportObject As ReportObject
    Dim crSubreportObject As SubreportObject
    Dim crDatabase As Database
    'Dim TableCounter
 
    'Set the ConnectionInfo properties for logging on to the Database
    With crConnectionInfo
      .ServerName = objBizUtilities.DB_Server
      .DatabaseName = objBizUtilities.DB_Name
      .UserID = objBizUtilities.DB_UserID
      .Password = objBizUtilities.DB_Password
    End With
    CrTables = RptDoc.Database.Tables
    'Loop through each table in the report and apply the LogonInfo information
    For Each CrTable In CrTables
      Try
        crTableLogonInfo = CrTable.LogOnInfo
        crTableLogonInfo.ConnectionInfo = crConnectionInfo
        CrTable.ApplyLogOnInfo(crTableLogonInfo)
        'If your DatabaseName is changing at runtime, specify the table location.
        CrTable.Location = objBizUtilities.DB_Name + ".fsww." & CrTable.Location.Substring(CrTable.Location.LastIndexOf(".") + 1)
        objfrmReportViewer.crptViewer.LogOnInfo.Add(crTableLogonInfo)
        RptDoc.Database.Tables(0).ApplyLogOnInfo(crTableLogonInfo)
      Catch ex As Exception
        MsgBox("Error Occured in the main report..." + ex.Message)
      Finally
        'objfrmReportViewer.crptViewer.LogOnInfo.Add(crTableLogonInfo)
      End Try
    Next
 
    'Set the sections collection with report sections
    crSections = RptDoc.ReportDefinition.Sections
 
    'Loop through each section and find all the report objects
    'Loop through all the report objects to find all subreport objects, then set the
    'logoninfo to the subreport
 
    For Each crSection In crSections
      crReportObjects = crSection.ReportObjects
      For Each crReportObject In crReportObjects
        If crReportObject.Kind = ReportObjectKind.SubreportObject Then
 
          'If you find a subreport, typecast the reportobject to a subreport object
          crSubreportObject = CType(crReportObject, SubreportObject)
 
          'Open the subreport
          subRptDoc = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName)
 
          crDatabase = subRptDoc.Database
          CrTables = crDatabase.Tables
 
          'Loop through each table and set the connection info
          'Pass the connection info to the logoninfo object then apply the
          'logoninfo to the subreport
 
          For Each CrTable In CrTables
            Try
              crTableLogonInfo = CrTable.LogOnInfo
              crTableLogonInfo.ConnectionInfo = crConnectionInfo
              CrTable.ApplyLogOnInfo(crTableLogonInfo)
              'If your DatabaseName is changing at runtime, specify the table location.
              CrTable.Location = objBizUtilities.DB_Name + ".fsww." & CrTable.Location.Substring(CrTable.Location.LastIndexOf(".") + 1)
              objfrmReportViewer.crptViewer.LogOnInfo.Add(crTableLogonInfo)
              RptDoc.Database.Tables(0).ApplyLogOnInfo(crTableLogonInfo)
            Catch ex As Exception
              MsgBox("Error Occured in the sub report..." + ex.Message)
            End Try
          Next
        End If
      Next
    Next
    'objfrmReportViewer.crptViewer.ReportSource = CR
  End Sub

Open in new window

0
mlmccCommented:
You have to have code in the application to change the database.
It looks like the code is there.  Is it referencing the correct database?

Crystal doesn't provide that ability in the login screen.

mlmcc
0
pandianfswwincAuthor Commented:
After setting logon info i inserted the below the code.
objfrmReportViewer.crptViewer.ReportSource = RptDoc

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
DB Reporting Tools

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.