?
Solved

Crystal Report showing static login dialog

Posted on 2008-11-17
5
Medium Priority
?
495 Views
Last Modified: 2013-11-15
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
0
Comment
Question by:pandianfswwinc
  • 2
  • 2
5 Comments
 
LVL 16

Expert Comment

by:wykabryan
ID: 22977213
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
 
LVL 101

Expert Comment

by:mlmcc
ID: 22977258
Are you changing the datasource in the application?

If so what code are you using?

Does the report have a subreport?

mlmcc
0
 

Author Comment

by:pandianfswwinc
ID: 22982303
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
 
LVL 101

Expert Comment

by:mlmcc
ID: 22987533
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
 

Accepted Solution

by:
pandianfswwinc earned 0 total points
ID: 23032988
After setting logon info i inserted the below the code.
objfrmReportViewer.crptViewer.ReportSource = RptDoc

Open in new window

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…
Stellar Phoenix SQL Database Repair software easily fixes the suspect mode issue of SQL Server database. It is a simple process to bring the database from suspect mode to normal mode. Check out the video and fix the SQL database suspect mode problem.

621 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