Crystal Reports数据库登录问题 [英] crystal reports database login problem

查看:98
本文介绍了Crystal Reports数据库登录问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
在客户端PC上部署具有水晶报表的应用程序作为报表工具时,我遇到了一个小问题.
自从我使用Access 2007以来,我就使用Microsoft.ACE.OLE DB.12.0提供程序. 我没有为数据库提供任何密码或用户名.但是它一直要求提供用户名和密码.
我正在使用VS的最新版本的Crystal Report(SP9)和客户端PC的运行时间.
这是我用来使用pull方法查看报告的代码.对我的编码或数据库连接的任何注释或修改都将不胜感激.

Hi all,
I had a little problem when deploying an application having crystal reports as a reporting tool on a client PC.
It works so well in my dev PC even installed.Since I''m using Access 2007 i used Microsoft.ACE.OLE DB.12.0 provider.
I haven''t provided any password or username for the database.But it keeps asking to provide a user name and a password.
I''m using the recent version of crystal reports (SP9) for VS and the run time for client PC.
Here is the code i used to view the report using the pull method.Any comment or modification on my coding or db connection is greatly appreciated.

Dim rep As New ReportDocument

        With rep
            .Load(ReportPath)
            .SetDataSource(ds)
        End With
        CrystalReportViewer1.ReportSource = rep
        CrystalReportViewer1.Show()

推荐答案

尝试以下操作:
使用DataSourceConnection类进行数据库登录 [
Try this:
Using the DataSourceConnection Class for Database Logon[^]

Basically you need to set the logon information to get the prompt to not appear, even if you haven''t password protected it. I believe your code would need to look something like this:

Dim rep As New ReportDocument

With rep
    .Load(ReportPath)
    'Assuming you've setup variables with the proper server, database, user, and password
    .DataSourceConnections.Item(0).SetConnection(strServerName, strDatabase, strUser, strPassword)
    .SetDataSource(ds)
End With
CrystalReportViewer1.ReportSource = rep
CrystalReportViewer1.Show()



希望对您有所帮助.



Hope this helps.


我只是通过提供服务器名称来使用此代码:
I just used this code by providing only the server name:
Dim rep As New ReportDocument
       Dim myTableLogonInfo As New TableLogOnInfo
       Dim myConnectionInfo As New ConnectionInfo
       'Dim myTables As Tables
       Dim myTable As Table
       rep.Load(ReportPath)
       rep.SetDataSource(ds)

       ' myTables = rep.Database.Tables
       With myConnectionInfo
           .ServerName = Application.StartupPath & "\projectpayrolls.accdb"
           .DatabaseName = ""
           .UserID = ""
           .Password = ""
       End With
       For Each myTable In rep.Database.Tables
           myTableLogonInfo = myTable.LogOnInfo
           myTableLogonInfo.ConnectionInfo = myConnectionInfo
           myTable.ApplyLogOnInfo(myTableLogonInfo)
       Next
       CrystalReportViewer1.ReportSource = rep


这篇关于Crystal Reports数据库登录问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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