Crystal Report始终要求数据库登录

时间:2013-01-22 13:42:49

标签: vb.net crystal-reports-2008

我需要你的帮助。

我正在为商店计划编写代码,而我正在使用vb.net 2008和Crystal Report版本10.5.37xxxx

问题是,当我尝试在客户端计算机上安装我的程序时,一切正常但不在我的Crystal Report中。它总是要求数据库登录,我没有编写我的程序来请求数据库登录。

我只是用简单的代码编写它:

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

任何人都可以帮我吗?

4 个答案:

答案 0 :(得分:1)

确保您的报告DataSource Provider设置为Microsoft OLE DB provider for SQL Server而不是SQL Server Native Client 10.0

答案 1 :(得分:1)

您应该能够手动编写登录凭据。

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 :(得分:0)

尝试开放式野外资源管理器--->数据库字段--->右键单击 - >当前数据源--->报告连接----->报告----->属性----> 将属性设为---

数据源:。\ Databasename.accdb

和查看器表单上的代码加载为

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")

也会更改与数据源相同的报表连接 我认为代码适合你......

答案 3 :(得分:0)

这将为您服务!

C#代码:


ConnectionInfo boconnectioninfo = new ConnectionInfo ();

boconnectioninfo.ServerName= "D-2818-w2k";

boconnectioninfo.DatabaseName ="NW";

boconnectioninfo.UserID ="sa";

boconnectioninfo.Password ="sa";

CrystalReportViewer1 .ReportSource = Server.MapPath("CrystalReport1.rpt");

TableLogOnInfos botableInfo= CrystalReportViewer1 .LogOnInfo;

            foreach (TableLogOnInfo obj2 in botableInfo)


            {
                obj2.ConnectionInfo =boconnectioninfo;

            }

Vb.net代码:



    Dim boconnectioninfo As New ConnectionInfo
        boconnectioninfo.ServerName = "sa"
        boconnectioninfo.DatabaseName = "sa"
        boconnectioninfo.UserID = "sa"
        boconnectioninfo.Password = "sa"
        Me.rptViewer.ReportSource = _ReportPath
        Me.rptViewer.SelectionFormula = _SelectionFormula
        If Not _ParameterFields Is Nothing Then
            Me.rptViewer.ParameterFieldInfo = _ParameterFields
        End If
        Dim a As TableLogOnInfos = Me.rptViewer.LogOnInfo





        ' Iterate through the list.
        For Each aa As TableLogOnInfo In a
            aa.ConnectionInfo = boconnectioninfo
        Next

        Me.Cursor = Cursors.Default
        rptViewer.Refresh()