Search code examples
vb.netcrystal-reports

Crystal Report asking for login credentials after changing target framework in VB.Net


All is fine when my target framework is .net Framework 4 but when I changed it to 4.8 it is suddenly asking me to put login credentials.

here is my code btw.

Dim cryRpt As New ReportDocument

        Dim connInfo As ConnectionInfo = New ConnectionInfo()
        connInfo.ServerName = tmpSN
        connInfo.DatabaseName = tmpDBN
        connInfo.UserID = tmpUID
        connInfo.Password = tmpPass
        Dim tableLogOnInfo As TableLogOnInfo = New TableLogOnInfo()
        tableLogOnInfo.ConnectionInfo = connInfo

        cryRpt.Load(reportsfolder + "NEWAPPFORM\AppForm.rpt")

        cryRpt.SetDataSource(tbIndividual)
        cryRpt.Subreports("Dependents.rpt").SetDataSource(cmdtableDep)

        For Each table As Table In cryRpt.Database.Tables
            table.ApplyLogOnInfo(tableLogOnInfo)
            table.LogOnInfo.ConnectionInfo.ServerName = connInfo.ServerName
            table.LogOnInfo.ConnectionInfo.DatabaseName = connInfo.DatabaseName
            table.LogOnInfo.ConnectionInfo.UserID = connInfo.UserID
            table.LogOnInfo.ConnectionInfo.Password = connInfo.Password
        Next

        .CrystalReportViewer1.ReportSource = cryRpt
        .CrystalReportViewer1.Refresh()
        .CrystalReportViewer1.ShowPrintButton = True
        .ShowDialog()

Solution

  • Solved it! I just changed the compile target to x86 and it is finally working again