Quantcast
Channel: SCN : Discussion List - SAP Crystal Reports, version for Visual Studio
Viewing all articles
Browse latest Browse all 3636

Login Prompt without database

$
0
0

I wrote an app with VS 2010 with the last version of Crystal reports for VS 2010. In my development pc works ok but when I deployed to another PC, it does not work, it always prompt for connection credentials but even when I enter right credentials it does not connect. I noticed that database textbox is empty so probably there is some issue.

I tried almost all ways and workaround to change connection at runtime without any success. I append some of my code... I hope somebody can help me or at least give me a clue of what is happening with my code...

 

 

Public Sub Initialize(ByVal _server As String, ByVal _database As String,

                          ByVal _user As String, ByVal _pass As String,

                          ByVal _reportPath As String, ByVal _defaultForm As String)

 

 

        rptViewerPricipal.ShowGroupTreeButton = False

        Server = _server

        Database = _database

        User = _user

        Pass = _pass

        ReportPath = _reportPath

        Copies= 1

        InitialPage = 0

        FinalPagel = 0

        Params = New Dictionary(Of String, Object)

        DefaultForm = _defaultForm

 

 

        If System.IO.File.Exists(ReportPath) Then

            ConnectionReport = New ConnectionInfo

            With ConnectionReport

                .ServerName = Server

                .DatabaseName = Database

                .UserID = User

                .Password = Pass

            End With

 

 

            CurrentReport = New ReportDocument()

            CurrentReport.Load(ReportPath)

            Dim dPrint As PrintDialog = New PrintDialog()

            For Each Myform As System.Drawing.Printing.PaperSize In dPrint.PrinterSettings.PaperSizes

                If Myform.PaperName = FormularioDefault Then

                    CurrentReport.PrintOptions.PaperSize =

                        CType(Myform.RawKind, PaperSize)

                End If

            Next

 

            SetDBLogonReport(ConnectionReport, CurrentReport)

            SetParamsReport()

            CurrentReport.PrintToPrinter(Copies, False, InitialPage, FinalPage)

        Else

            Throw New Exception("Hubo un problema a la hora de cargar el archivo del reporte, por favor reintente o contacte al administrador del sistema.")

        End If

 

 

    End Sub

 

 

Private Sub SetParametrosReporte()

        For Each paramName As String In Parametros.Keys

            Dim paramDV As New ParameterDiscreteValue()

            paramDV.Value = _parametros(paramName)

            CurrentReport.ParameterFields(paramName).CurrentValues.Add(paramDV)

        Next

    End Sub

 

 

    Private Sub SetDBLogonReport(ByRef connectionInfo As ConnectionInfo, ByRef reportDocument As ReportDocument)

        Dim myTables As Tables = reportDocument.Database.Tables

        Try

            For Each myTable As CrystalDecisions.CrystalReports.Engine.Table In myTables

                Dim myTableLogonInfo As TableLogOnInfo = myTable.LogOnInfo

                myTableLogonInfo.ConnectionInfo = connectionInfo

                myTable.ApplyLogOnInfo(myTableLogonInfo)

                ''myTable.Location = myTable.Location.Substring(myTable.Location.LastIndexOf(".") + 1)

                ''"Northwind.dbo." &

            Next

 

 

            'SetDBLogonForSubreports(myConnectionInfo, myReportDocument)

            CurrentReport.DataSourceConnections(0).SetConnection(Servidor, BaseDatos, Usuario, Clave)

        Catch ex As Exception

            Throw New Exception("Error a la hora de establecer la conexion a la base de datos del reporte." & ex.Message)

        End Try

    End Sub


Viewing all articles
Browse latest Browse all 3636

Trending Articles