Home > OS >  Why Crystal Reports prompts for credentials with no database name in LAN PC?
Why Crystal Reports prompts for credentials with no database name in LAN PC?

Time:09-21

Specifications

  • Using SQL Server as backend
  • Writing a VB.NET desktop application

Issue

  • Crystal Reports is working fine on the server PC (where SQL Server is installed) but prompting for credentials on a LAN-connected PC.
  • Problem is that the prompt didn't even have database name so every login credentials entered is wrong as shown in image below.

Issue Image 1

Other Info

  • I've made another project which has Crystal Reports and it's working fine there (even on the LAN PC) and actually I copied the code from there and changed the required data.

What I tried

This is the code I tried to run:

  With orptname
                .DataSourceConnections.Clear()
                .DataSourceConnections.Item(0).SetConnection("tcp:" & PubServer & "," & PubPort, Pubdbname, PubUid, PubPwd)
                '.SetDatabaseLogon(PubUid, PubPwd, PubServer & "," & PubPort, Pubdbname)
                '.DataSourceConnections.Item(0).SetConnection(PubServer & "," & PubPort, Pubdbname, PubUid, PubPwd)
                'MsgBox("USER ID" & PubUid & " | PASSWORD : " & PubPwd & " | DB NAME : " & Pubdbname & " | SERVER : " & PubServer & " | PORT : " & PubPort)
                 SOME OF MY REPORT PARAMETERS
  End With

My current code:

Dim report as New Report Document
report = New DateWise
report.Load(reportAddress & tempAddr1) '---- This line works correctly (also works if I eleminate this line in SERVER PC)

DisplaySummary(report, jsondata)

'IN DisplaySummary method
 Public Sub DisplaySummary(ByVal orptname As ReportDocument, JData As String)
    Dim fdate, tdate As Date
    Dim Param1 As String = Nothing
    Dim SBkCd, TransType, Common, CYN, FBill, TBill, SBill, DonCode, AcCode, DocCode As String
    Try
        SBkCd = 0 : TransType = "" : Common = "" : CYN = 0 : FBill = 0 : TBill = 0 : SBill = 0 : DonCode = 0 : AcCode = 0 : DocCode = 0
        If JData <> Nothing Then
            Dim jsonResult = JsonConvert.DeserializeObject(Of Dictionary(Of String, Object))(JData)
            SBkCd = jsonResult.Item("filter").Item("SBkCd")
        End If

        With orptname
            .DataSourceConnections.Clear()
            '.DataSourceConnections.Item(0).SetConnection("tcp:**********" & "," & PubPort, Pubdbname, PubUid, PubPwd)
            .DataSourceConnections.Item(0).SetConnection("tcp:" & PubServer & "," & PubPort, Pubdbname, PubUid, PubPwd)
            '.SetDatabaseLogon(PubUid, PubPwd, PubServer & "," & PubPort, Pubdbname)
            '.DataSourceConnections.Item(0).SetConnection(PubServer & "," & PubPort, Pubdbname, PubUid, PubPwd)
            'MsgBox("USER ID" & PubUid & " | PASSWORD : " & PubPwd & " | DB NAME : " & Pubdbname & " | SERVER : " & PubServer & " | PORT : " & PubPort)
            .SetParameterValue("@Sbill", SBill)
            .SetParameterValue("CName", PubCName)
            Dim filename As String = rptcode.Substring(2, rptcode.Length - 2) & "--" & Format(CDate(fdate), "ddMMyyyy") & "-" & Format(CDate(tdate), "ddMMyyyy")
            filename = filename.Replace("\", "")
            filename = filename.Replace("/", "")
            filename = filename.Replace(":", "")
            filename = filename.Replace("*", "")
            filename = filename.Replace("?", "")
            filename = filename.Replace("""", "")
            filename = filename.Replace("<", "")
            filename = filename.Replace(">", "")
            filename = filename.Replace("|", "")
            .SummaryInfo.ReportTitle = filename
        End With

        Dim CrExportOptions As New ExportOptions
        Dim CrDiskFileDestinationOptions As New DiskFileDestinationOptions()
        Dim CrFormatTypeOptions = Nothing
        Dim exportpath As String = Nothing

        If rpttype <> 0 Then
            exportpath = Path.Combine(Directory.GetCurrentDirectory(), "Exports")
            CrDiskFileDestinationOptions.DiskFileName = exportpath
            CrExportOptions = orptname.ExportOptions
            CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile
        End If

        Select Case rpttype
            Case 0 ' CRYSTAL REPORT
                Using obj As New CReports
                    obj.CRViewer.ReportSource = orptname
                    obj.ShowDialog()
                    obj.CRViewer.ReportSource = Nothing
                    obj.CRViewer.Dispose()
                End Using
            Case 1 ' PDF
                CrFormatTypeOptions = New PdfFormatOptions
                CrDiskFileDestinationOptions.DiskFileName = exportpath & "\" & orptname.SummaryInfo.ReportTitle & ".pdf"
                CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat
            Case 2 ' EXCEL
                CrFormatTypeOptions = New ExcelFormatOptions
                CrDiskFileDestinationOptions.DiskFileName = exportpath & "\" & orptname.SummaryInfo.ReportTitle & ".xlsx"
                CrExportOptions.ExportFormatType = ExportFormatType.ExcelWorkbook
            Case 3 ' WORD
                CrFormatTypeOptions = New PdfRtfWordFormatOptions
                CrDiskFileDestinationOptions.DiskFileName = exportpath & "\" & orptname.SummaryInfo.ReportTitle & ".rtf"
                CrExportOptions.ExportFormatType = ExportFormatType.WordForWindows
        End Select
Catch ex As Exception
    Throw
End Try
End Sub

Note

  • My first project's Crystal Reports worked correctly even on the LAN PC
  • Database of both current and previous projects are different, server instance are the same.

UPDATE :

  • I tried to open the report in Project 1 where other reports were opening and the report didn't even open from there. so is this possibly something from Database?

CodePudding user response:

Ok I got the answer.
This all because the connection provider.

I researched my previous connection properties and found that the Provider name in Crystal Report connection is different. Then I tried making all other connections for SQL Server and found the provider the one I used previously.

Following Image shows the issue and solution for my problem. Solution Image

Hope this helps someone else. !

  • Related