2012-04-03 18 views
0

Crystal Reportsを書き直す作業がありました。私は元のレポートを1999年頃に見つけ、VS 2008でそれらを開いて変更を加えて保存しました。オブジェクトデータセットを使用したCrystalレポート

今、それらはもはや周囲のデータベースを参照します。だから、私はこのデータソースを削除し、.NET OBJECTデータソースを追加しました。フィールドがこの新しいデータソースを参照するように、すべてを変更しました。

私の意図は、レポートを作成し、実行時にデータテーブルに渡すことでした。このテーブルは作成されたsprocを実行することによって作成されます。

私が実行すると、レポートの最初のページが表示されます。私はページまたはプリントを変更しようとすると、しかし、私はエラーを取得する:ここで

Logon failed. Details: crdb_adoplus : Object reference not set to an instance of an object. Error in File C:...\MR01 {8E5164A9-4B01-4019-81E6-87AED65A02DF}.rpt: Unable to connect: incorrect log on parameters

は私のコードは次のとおりです。

<CR:CrystalReportViewer ID="theCrystalReportViewer" visible="false" runat="server" EnableDatabaseLogonPrompt="false" /> 


     Dim theDataTable As DataTable = tbl 
     theDataTable.TableName = "tableName" 
     Dim oReport As New ReportDocument 

     Dim sRptPath As String = "...Reports\MR01.rpt" 
     oReport.Load(sRptPath) 
     oReport.SetDataSource(theDataTable) 
     'oReport.SetDatabaseLogon("####", "####", "####", "#####") 


     Dim c As ConnectionInfo = New ConnectionInfo() 
     c.ServerName = "####" 
     c.DatabaseName = "####" 
     c.Password = "####" 
     c.UserID = "####" 
     c.Type = ConnectionInfoType.SQL 
     c.IntegratedSecurity = False 

     For i As Integer = 0 To theCrystalReportViewer.LogOnInfo.Count - 1 
      theCrystalReportViewer.LogOnInfo(i).ConnectionInfo = c 
     Next 


     'theCrystalReportViewer.EnableDatabaseLogonPrompt = False 
     'theCrystalReportViewer.DisplayGroupTree = False 
     theCrystalReportViewer.ReportSource = oReport 
     theCrystalReportViewer.DataBind() 

     litMsg.Visible = False 
     theCrystalReportViewer.Visible = True 

答えて

0

はこちらの指示に従って試してみてください。http://vb.net-informations.com/crystal-report/vb.net_crystal_report_without_database.htm

私はあなたが必要になると思いますあまりにもこのを取り除くために:

Dim c As ConnectionInfo = New ConnectionInfo() 
    c.ServerName = "####" 
    c.DatabaseName = "####" 
    c.Password = "####" 
    c.UserID = "####" 
    c.Type = ConnectionInfoType.SQL 
    c.IntegratedSecurity = False 

    For i As Integer = 0 To theCrystalReportViewer.LogOnInfo.Count - 1 
     theCrystalReportViewer.LogOnInfo(i).ConnectionInfo = c 
    Next 
+0

ありがとうございますが、それは私が探していたものではありません。この記事では、カスタムデータセットを手動で入力してレポートにプッシュする方法を示します。私はsprocで満たされたカスタムデータセットを作成し、それをレポートにプッシュしたいと考えています。 – user1310989

+0

レポートをsprocに直接接続するのではなく、データセット経由でsproc結果を渡す目的は何ですか? –

0

JGauffin、

Leeと同じように、クリスタルレポートに資格情報を渡すのではなく、ストアドプロシージャのデータでデータセットを読み込むのはなぜか不思議です。

実際、表示するコードでは、データセットを直接読み込むことさえできません。ストアドプロシージャを使用してデータサーバーから直接データをプルすることをお勧めします。これは、サーバーにアクセスするための資格情報を設定するだけです。あなたが唯一のページング、印刷およびエクスポートに問題が表示された場合、

// this line needs you to replace these arguments with the valid values 
oReport.SetDatabaseLogon("your", "valid", "settings", "here"); 

:あなたは...

Dim c As ConnectionInfo = New ConnectionInfo() 
c.ServerName = "####" 
c.DatabaseName = "####" 
c.Password = "####" 
c.UserID = "####" 
c.Type = ConnectionInfoType.SQL 
c.IntegratedSecurity = False 

For i As Integer = 0 To theCrystalReportViewer.LogOnInfo.Count - 1 
theCrystalReportViewer.LogOnInfo(i).ConnectionInfo = c 
Next 

をすべてこのコードを削除する場合

...あなたはこの便利なメソッドを再導入することができます、ReportSourceをビューに設定し直してください。

if (!IsPostBack) 
{ 
// all your existing code should go in here 
// this includes the SetDatabaseLogon etc. 
// at the right moment, save your oReport in session 
Session["myReportDocument"] = oReport; 
theCrystalReportViewer.ReportSource = oReport; 
} 
else // we are posting back, so make sure the viewer still has the report object 
{ 
theCrystalReportViewer.ReportSource = (ReportDocument)Session["myReportDocument"]; 
} 

私はこれが正しい経路であなたを得ることを望みます。

関連する問題