2012-01-10 56 views
0

我製作了一個包含Crystal Report的小型VB.NET應用程序。在機器上運行水晶報告我使它完美。當我在筆記本電腦上運行應用程序時,Crystal Report總是提示我輸入登錄事件,儘管數據庫沒有設置登錄名。我試着用代碼傳遞「Admin」和「」,但沒有運氣。Crystal Reports提示僅在其他PC上登錄

我與Access數據庫的工作,這是我必須加載我的水晶報表代碼:

If frmReport Is Nothing OrElse frmReport.IsDisposed Then 
    frmReport = New frmReport 
End If 

frmReport.CrystalReportViewer1.ReportSource = "../../Reports/Klantenbeheer.rpt" 

frmReport.MdiParent = Me 
frmReport.Show() 

我沒看Prevent login of ODBC Text driver in Crystal Report for Visual Studio 2010,但我不知道它是否適用於我的情況?

我也嘗試將rpt的數據源設置爲我在應用程序中使用的數據源,然後將其分配給ReportSource,但沒有運氣。

有些人發現從DAO轉換到OLEDB的解決方案,但我從一開始就使用了OLEDB。

回答

0

也許在at the bottom of this thread找到的代碼可以幫助你?具體來說:

Imports CrystalDecisions.Shared 
Imports CrystalDecisions.CrystalReports.Engine 

Dim myConnectionInfo As ConnectionInfo = New ConnectionInfo() 
Dim myReport As New ReportDocument() 
myReport.Load(Server.MapPath("ReportName")) 'name of your Crystal Report - see note below 

Dim myTables As Tables = myReport.Database.Tables 

For Each myTable As CrystalDecisions.CrystalReports.Engine.Table In myTables 
Dim myTableLogonInfo As TableLogOnInfo = myTable.LogOnInfo 
myConnectionInfo.ServerName = <SQL servername> 
myConnectionInfo.DatabaseName = "" 'leave database name blank 
myConnectionInfo.UserID = 'login name 
myConnectionInfo.Password = 'password 
myTableLogonInfo.ConnectionInfo = myConnectionInfo 
myTable.ApplyLogOnInfo(myTableLogonInfo) 
Next 

CrystalReportViewer1.ReportSource = myReport 

它是爲ASP.Net製作的,但可能會稍作調整?

+0

我嘗試了一種循環遍歷myTables並將它們各自的位置設置爲Access數據庫的類似方法。不幸的是,這會拋出一個COMException異常。 – Mekswoll 2012-01-10 06:57:45

0

嗯,我知道這是一個老問題。但我想我應該只是添加一個信息,我有一個鏈接,經過痛苦的研究,他告訴我們,我們必須複製正確版本的crdb_ado.dll。請在此閱讀:XtremeNetTalk。不幸的是,我還沒有能夠在互聯網上找到該文件!我希望我能用這個完成這個答案。