簡體   English   中英

為什么 Crystal Reports 在 LAN PC 中提示輸入沒有數據庫名稱的憑據?

[英]Why Crystal Reports prompts for credentials with no database name in LAN PC?

規格

  • 使用 SQL 服務器作為后端
  • 編寫 VB.NET 桌面應用程序

問題

  • Crystal Reports 在服務器 PC 上運行良好(安裝了 SQL 服務器),但在連接 LAN 的 PC 上提示輸入憑據。
  • 問題是提示甚至沒有數據庫名稱,因此輸入的每個登錄憑據都是錯誤的,如下圖所示。

問題圖片 1

其他信息

  • 我已經制作了另一個項目,其中包含 Crystal Reports,它在那里運行良好(即使在 LAN PC 上),實際上我從那里復制了代碼並更改了所需的數據。

我試過的

這是我嘗試運行的代碼:

  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

我當前的代碼:

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

筆記

  • 我的第一個項目的 Crystal Reports 即使在 LAN PC 上也能正常工作
  • 當前和以前項目的數據庫不同,服務器實例相同。

更新:

  • 我試圖在項目 1 中打開其他報告正在打開的報告,但報告甚至沒有從那里打開。 那么這可能來自數據庫嗎?

好的,我得到了答案。
這一切都是因為連接提供者。

我研究了我之前的連接屬性,發現水晶報表連接中的Provider名稱不一樣。 然后我嘗試為 SQL 服務器建立所有其他連接,並找到了我之前使用的提供程序。

下圖顯示了我的問題的問題和解決方案。 解決方案圖片

希望這對其他人有幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM