簡體   English   中英

具有Crystal Reports的MySQL DSN連接的VB.NET應用程序要求登錄信息

[英]VB.NET application with MySQL DSN connection for Crystal Reports asks for Logon info

我有一個用VB.NET編寫的應用程序。 前段時間它是為客戶使用32位體系結構編寫的。 該數據庫是MySQL 5.5。 這些報表是內置的Crystal報表,數據庫連接是通過DSN的ODBC 32位MySQL連接器。

現在,客戶端已將所有客戶端升級到Windows 10(64位)。 桌面應用程序可以與相同的舊32位連接器一起很好地工作,但是當運行任何報告時,它都會要求登錄屏幕。 不幸的是,在運行時傳遞登錄憑據無效。

該代碼如附件所示。 我已經瀏覽了所有答案,但是代碼不起作用。 我有什么想念的嗎? 有人可以幫忙嗎? 我知道這個問題是個老問題,但是它已經運行了好幾年了,我們真的不需要重寫。

代碼:(在按鈕鏈接上調用)

 Public Sub PrintAmcRemainderForIndus(ByVal componentId As Integer, ByVal AddressId As Integer)         
   'Dim cryRpt As New ReportDocument
        Dim rPath As String = ""
        Dim objForm As New frmViewReport
    rPath = Application.StartupPath & "\Reports\rptAMCReminderForIndus.rpt"'
    MessageBox.Show(rPath.Length & vbCrLf & rPath)
    Dim crtableLogoninfos As New TableLogOnInfos()
    Dim crtableLogoninfo As New TableLogOnInfo()
    Dim crConnectionInfo As New ConnectionInfo()
    Dim CrTables As Tables
    Dim CrTable As Table
    Dim TableCounter

    Dim cryRpt As New rptAMCReminderForIndus()


    'If you are using ODBC, this should be the DSN name NOT the physical server name. If
    'you are NOT using ODBC, this should be the
    'physical server name

    With crConnectionInfo
        .ServerName = "Indus"

        'If you are connecting to Oracle there is no
        'DatabaseName. Use an empty string.
        'For example, .DatabaseName = ""

        .DatabaseName = "indus"
        .UserID = "root"
        .Password = "simsoft"
    End With

    'This code works for both user tables and stored
    'procedures. Set the CrTables to the Tables collection
    'of the report
    CrTables = cryRpt.Database.Tables


    For Each CrTable In CrTables
        crtableLogoninfo = CrTable.LogOnInfo
        crtableLogoninfo.ConnectionInfo = crConnectionInfo
        CrTable.ApplyLogOnInfo(crtableLogoninfo)
    Next

    Try

        'cryRpt.Load(rPath)

        Dim crParameterFieldDefinitions As ParameterFieldDefinitions
        Dim crParameterFieldDefinition As ParameterFieldDefinition
        Dim crParameterValues As New ParameterValues
        Dim crParameterDiscreteValue As New ParameterDiscreteValue

        crParameterValues.Clear()

        crParameterDiscreteValue.Value = componentId
        crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields
        crParameterFieldDefinition = crParameterFieldDefinitions.Item("piCustomerId")
        crParameterValues = crParameterFieldDefinition.CurrentValues
        crParameterValues.Add(crParameterDiscreteValue)
        crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)

        crParameterDiscreteValue.Value = AddressId
        crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields
        crParameterFieldDefinition = crParameterFieldDefinitions.Item("piAddressId")
        crParameterValues = crParameterFieldDefinition.CurrentValues
        crParameterValues.Add(crParameterDiscreteValue)
        crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)

        objForm.rptViewer.ReportSource = cryRpt
        objForm.Show()
    Catch ex As Exception
        MessageBox.Show(ex.Message & vbCrLf & ex.InnerException.Message)
    End Try


End Sub

我會說這里有問題:

'If you are using ODBC, this should be the DSN name NOT the physical server name. If
'you are NOT using ODBC, this should be the
'physical server name

With crConnectionInfo
    .ServerName = "Indus"

您確定要提供ODBC的名稱,而不是主機名嗎?

在這里看看:

http://www.tek-tips.com/faqs.cfm?fid=4870

和這里:

如何為Crystal Report vb.net設置數據庫登錄信息(連接信息)?

暫無
暫無

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

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