2017-01-03 6 views
0

私はこの質問に関するすべての質問と回答をstackoverflowで読んだ。Crystalがデータベースのログイン資格情報を要求する理由を教えてください。

しかし、私はこれらの質問から助けを得ることはできません。

私のコード

Imports System.Data.SqlClient Imports System.Data Imports System.Windows.Forms Imports CrystalDecisions.Shared Partial Class Reports_LReport Inherits System.Web.UI.Page Public Report As New CrystalDecisions.CrystalReports.Engine.ReportDocument() Public thisConnectionString As String = ConfigurationManager.ConnectionStrings("cnStringMain").ConnectionString Dim reportDocument As CrystalDecisions.CrystalReports.Engine.ReportDocument = Nothing Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Dim scriptManager__1 As ScriptManager = ScriptManager.GetCurrent(Me) scriptManager__1.RegisterPostBackControl(Me.FactroyAttendance) If Not IsPostBack = True Then Else LoadReport() End If End Sub Protected Sub cmdShow_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdShow.Click LoadReport() End Sub Private Sub LoadReport() If Me.reportDocument IsNot Nothing Then Me.reportDocument.Close() Me.reportDocument.Dispose() End If Dim SConn As New SqlConnectionStringBuilder(ConfigurationManager.ConnectionStrings("cnStringMain").ConnectionString) Dim thisConnection As New SqlConnection(thisConnectionString) Dim mySelectCommand As SqlCommand = New System.Data.SqlClient.SqlCommand("prLeaveStatusReport", thisConnection) mySelectCommand.CommandType = CommandType.StoredProcedure reportDocument = New CrystalDecisions.CrystalReports.Engine.ReportDocument() Dim reportPath As String = Server.MapPath("~/Reports/JoyLeaveReport.rpt") reportDocument.Load(reportPath) Dim connInfo As New CrystalDecisions.Shared.ConnectionInfo() connInfo.ServerName = SConn.DataSource connInfo.DatabaseName = SConn.InitialCatalog connInfo.UserID = SConn.UserID connInfo.Password = SConn.Password Dim tableLogOnInfo As New CrystalDecisions.Shared.TableLogOnInfo() tableLogOnInfo.ConnectionInfo = connInfo For Each table As CrystalDecisions.CrystalReports.Engine.Table In reportDocument.Database.Tables table.ApplyLogOnInfo(tableLogOnInfo) table.LogOnInfo.ConnectionInfo.ServerName = connInfo.ServerName table.LogOnInfo.ConnectionInfo.DatabaseName = connInfo.DatabaseName table.LogOnInfo.ConnectionInfo.UserID = connInfo.UserID table.LogOnInfo.ConnectionInfo.Password = connInfo.Password table.Location = "dbo." + table.Location Next If String.IsNullOrEmpty(txtFrom.Text) Then reportDocument.SetParameterValue("@dateFrom", "") Else reportDocument.SetParameterValue("@dateFrom", Convert.ToDateTime(txtFrom.Text).ToString("yyyy-MM-dd HH:mm:ss")) End If If String.IsNullOrEmpty(txtEmployeeID.Text) Then reportDocument.SetParameterValue("@empId", "") Else reportDocument.SetParameterValue("@empId", txtEmployeeID.Text) End If If String.IsNullOrEmpty(txtTo.Text) Then reportDocument.SetParameterValue("@dateTo", "") Else reportDocument.SetParameterValue("@dateTo", Convert.ToDateTime(txtTo.Text).ToString("yyyy-MM-dd HH:mm:ss")) End If FactroyAttendance.ReportSource = reportDocument FactroyAttendance.DataBind() FactroyAttendance.ReportSource = reportDocument FactroyAttendance.DataBind() End Sub Protected Sub Page_Unload(ByVal sender As Object, ByVal e As EventArgs) If Me.reportDocument IsNot Nothing Then Me.reportDocument.Close() Me.reportDocument.Dispose() End If End Sub End Class 

は、私は私が3つのフィールド1 FROMDATE 2. TODATE 3.社員を持ってどこから持って

私のレポートは、正常に動作しているが、私は、エクスポートするつもりですときpdfまたはwordでレポートして、パラメータとデータベースログインの値を私に尋ねます。

画像1

enter image description here

画像2 enter image description here

画像3 enter image description here

だから、私は私のSIから説明してきました可能な限りテ。 どうすれば解決できますか? 事前に感謝します。

+0

[サブレポートを開くときにログイン資格情報を求めてから、Crystalレポートビューアを停止する方法]の可能な重複(http://stackoverflow.com/questions/21709438/how-to-stop-crystal-report-viewer-from-asking- login-credentials-when-opening-sub) –

+0

あなたの質問に答えてください、私は助けを得ていません。 –

答えて

1

は、私はあなたが右のログオン情報を入れていることがわかり、その問題はあなたのcrystalreportオブジェクトをキャッシュしていないことが考えられます。

あなたがオブジェクトをキャッシュし、あなたのウェブページのPage_Initウェブ方法で再びそれをバインドする必要があります。あなたのレポートに複数のページを持ち、エクスポートするときには、それは必要です。このdocで

詳細情報:例えばhttp://help.sap.com/businessobject/product_guides/sapCRVS2010/en/crnet13_sp14_dg_en.pdf

ページ56(セクション1.3.3.4)。

+0

私は助けを得ていません。もう一度レポートを作成する必要がありますか? –

+1

crystalreportオブジェクトをキャッシュし、ページinitでそれを取得し、 'FactroyAttendance.ReportSource = reportDocument;を実行する必要があります。 FactroyAttendance.DataBind(); ' – Furtiro

+0

解決済み:メソッドを追加するだけです。ここでFactoryAttendanceはcrystalViewerです。 [プロテクト.FactroyAttendance_Load(オブジェクトとしてByVal送信者は、のEventArgsとしてByVal e)はFactroyAttendance.Load LoadReport() エンドサブハンドルサブ] –

関連する問題