Crystal Report always asks for database login

2019-02-25 22:36发布

问题:

I need your help.

I'm writing code for a shop program and I am using vb.net 2008 with Crystal Report version 10.5.37xxxx

The problem is when I'm trying to install my program on the client computer, everything works but not in my Crystal Report. It always asks for the database login and I did not code my program to ask for the database login.

I just wrote it in simple code like this:

Public Class Form16

    Private Sub Form16_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim view As New CrystalReport4
        view.SetParameterValue("p_1", Form5.no_faktur_tb_immanuel)
        CrystalReportViewer1.ReportSource = view
    End Sub

End Class

Can anyone help me with this?

回答1:

You should be able to manually code the login credentials.

Public Class Form16

    Private Sub Form16_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim view As New CrystalReport4
        Dim user as string = "Username"
        Dim pwd as string = "Password"

        view.SetDatabaseLogon(user, pwd)
        view.SetParameterValue("p_1", Form5.no_faktur_tb_immanuel)
        CrystalReportViewer1.ReportSource = view

    End Sub

End Class


回答2:

Make Sure your Report DataSource Provider is set to Microsoft OLE DB provider for SQL Server and not SQL Server Native Client 10.0



回答3:

try that open field explorer---> database field --->Right Click -->current Data source --->reports connection----->report ----->property ----> set Property as---

Data Source: .\Databasename.accdb

and code on viewer form load as

Dim cryRpt As New ReportDocument

    Dim Report1 As New rptItemWise

    Dim strServerName As String
    strServerName = Application.StartupPath
rptItemWise.SetDatabaseLogon("admin", "", strServerName, "dastabasename.accdb", True)



    cryRpt.Load(Application.StartupPath + "\rptItemWise.rpt")

also change the report connection same as data source i think that code work for you ....