如何为Crystal Report vb.net设置数据库登录信息(连接信息)? [英] How to set database login infos (connection info) for crystal report vb.net?

查看:121
本文介绍了如何为Crystal Report vb.net设置数据库登录信息(连接信息)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让Crystal Reports设置登录时遇到了一些问题。我在许多报告中都使用了它,但是由于某种原因,有几个已经停止了工作。随附的是我的登录脚本,我已经逐步完成了它,并且登录信息在每一步之后都已存在。

更为不寻常的是,Visual Studio中的报表将打开并显示信息,

I am having a little problem getting Crystal Reports to set the logon. I have it working in a number of reports but a couple for some reason have stopped working. Attached is my logon script, I have stepped through it and the logon info is all there after every step.
What is even more unusual is that the report in visual studio will open with information OK

Private Sub cmdPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdPrint.Click
    Dim cryRpt As New ReportDocument
    Dim crTableLogonInfos As New TableLogOnInfos
    Dim crTableLogonInfo As New TableLogOnInfo
    Dim crConnectionInfo As New ConnectionInfo
    Dim crTables As Tables
    Dim crTable As Table
    cryRpt.Load("g:\dt2\rptMusterSheet.rpt")
    With crConnectionInfo
        .ServerName = "SERVERNAME"
        .DatabaseName = "DB NAME"
        .UserID = "sa"
        .Password = "xxxxxxx"
    End With
    crTables = cryRpt.Database.Tables
    For Each crTable In crTables
        crTableLogonInfo = crTable.LogOnInfo
        crTableLogonInfo.ConnectionInfo = crConnectionInfo
        crTable.ApplyLogOnInfo(crTableLogonInfo)
    Next
    CRV1.ReportSource = cryRpt
    CRV1.Refresh()
End Sub

单步执行后,我得到此消息框

after stepping through I get thisMessage Box

推荐答案

尝试一下...

Dim mytableloginfos As New TableLogOnInfos()
mytableloginfos = CRV1.LogOnInfo
For Each myTableLogOnInfo As TableLogOnInfo In mytableloginfos
    myTableLogOnInfo.ConnectionInfo = crConnectionInfo
Next

这篇关于如何为Crystal Report vb.net设置数据库登录信息(连接信息)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆