Problem with Crystal Repots reports when connecting to server

0

I have a problem wanting to generate reports from a database that is on a server, what happens is that when I perform local tests, I can generate the reports without problems, but when I try to assign it to the "ServerName" parameter in my code a server name that contains an ip address throws me the following error:

Security is integrated, so I do not require access data. the connection to the database is presented without problems, because I can perform procedures for saving, deletion and updating, the problem arises when wanting to generate the reports. then a fragment of the code.

linea = objReader.ReadLine()
    Dim a As Integer = InStr(13, linea, "=", CompareMethod.Text) + 2
    Dim b As Integer = InStr(a, linea, ";", CompareMethod.Text)
    Dim dbase As String = Mid(linea, a, b - a)
    linea = objReader.ReadLine()
    objReader.Close()
    Dim crConInfo As New ConnectionInfo
    Dim crLogInfo As New TableLogOnInfo
    With crConInfo
        .ServerName = linea
        .DatabaseName = dbase '"Data"
        .IntegratedSecurity = True
        .Type = ConnectionInfoType.Query
    End With
    crLogInfo.ConnectionInfo = crConInfo
    Try
        Dim fechaInicio As String = Format(Date.Parse(txtFechaInicial.Text), "yyyy-MM-dd")
        Dim fechaFin As String = Format(Date.Parse(txtFechaFinal.Text), "yyyy-MM-dd")
        If cmbProceso.Text = "Despacho" Then
            If cmbReporteTipo.Text = "Simple" Then
                'Dim ReportePlanta As New objeto
                For Each tabla As Table In Objeto.Database.Tables
                    crLogInfo = tabla.LogOnInfo
                    crLogInfo.ConnectionInfo.ServerName = "192.30.1.29\MSSQLSERVER"
                    crLogInfo.ConnectionInfo.DatabaseName = dbase
                    tabla.ApplyLogOnInfo(crLogInfo)
                Next
                Objeto.Refresh()

At the end of the whole operation I end with the following lines.

            Formulario.CrystalReportViewer1.ReportSource = Objeto
        Objeto.Refresh()
        If Formulario.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
            Formulario.Close()
        End If

Could someone help me by telling me what is the proper procedure to generate reports from a database that is on a server? Thank you in advance for the help you can give me.

    
asked by Benkos 27.04.2017 в 18:49
source

1 answer

1

In my case I had the same problem and I found the solution outside of visual studio.

You have to create an .dsn file with the Windows text editor and include in it the access data to the database (server, name, password and user).

Then save the dsn file created in the path:

  • WINDOWS XP:

      

    C: \ Program Files \ Common Files \ ODBC \ Data Sources

  • WINDOWS 7 AND 8:

    • For 32 bits:
        

      C: \ Program Files (x86) \ Common Files \ ODBC \ Data Sources

    • For 64 bits:
        

      C: \ Program Files \ Common Files \ ODBC \ Data Sources

If they do not exist, create them.

Then you add the dsn file to:

  

System Tools / Data Source Administrator.

I pass a link to the document that I have as a guide:

link

    
answered by 10.06.2017 в 09:47