3

我有幾十個遺留報告,其中許多都使用Sql Server存儲過程作爲其數據源。我試圖在使用VB.NET 2010CR爲Visual Studio 2010版本13.0.2構建的應用程序中使用它們。如何在存儲過程中創建Crystal報表?

當我運行基於存儲過程的報告,我得到一個錯誤消息,說像

表「REPORT_SCHEDULEB」找不到

表定義報告外觀像這樣:

LogOnInfo.ConnectionInfo for REPORT_SCHEDULEB: 
Name: "REPORT_SCHEDULEB", Location: "Proc(REPORT_SCHEDULEB;1)" 
AllowCustomConnection: False, DBName: myDb, IntegratedSecurity: False 
ServerName: myComputer, User: myName, Password: myPassword, Attributes: 
    Database DLL: crdb_ado.dll 
    QE_DatabaseName: myDb 
    QE_DatabaseType: OLE DB (ADO) 
     Auto Translate: -1 
     Connect Timeout: 0 
     Data Source: myComputer 
     General Timeout: 0 
     Initial Catalog: myDb 
     Integrated Security: False 
     Locale Identifier: 1033 
     OLE DB Services: -5 
     Provider: SQLOLEDB 
     Tag with column collation when possible: 0 
     Use DSN Default Properties: False 
     Use Encryption for Data: 0 
     Owner: dbo 
    QE_ServerDescription: myComputer 
    QE_SQLDB: True 
    SSO Enabled: False 
    Owner: dbo 

我猜有一些問題與方式位置字段定義,但

  1. 當我試圖改變重寫限定的表名在 報告編輯器也不會接受變化,並
  2. 我真的寧願找一個綱領性的解決方案比手動編輯幾十個報告。

所以,我試着在我的代碼中設置table.Location值,但是會拋出一個COM異常 - 我猜它只是在某個級別上是隻讀的。

我也想過設置某種QualifiedName屬性的可能性,但還沒有找到辦法做到這一點。

任何想法?

TIA

回答

0

我已經通過使用從存儲過程創建一個DataTable在運行時設置報表數據源實現了VB的解決方案。這樣,所有連接細節只需要在應用程序中存儲一次,而不是針對每個報告。

(大致)

Dim SourceDatabase as datatable = GetDatatableFromSP(SPName) 
Dim DocumentToShow as New ReportDocument 

DocumentToShow.Load(DocumentPath) 
DocumentToShow.SetDataSource(SourceDatabase) 

ReportViewer.ViewerCore.ReportSource = DocumentToShow