我已经阅读了有关stackoverflow中相关问题的所有问题和答案。
但我无法从这些问题中获得帮助。
我的代码
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
我有一个来自哪里我有三个领域1. Fromdate 2. Todate 3. EmployeeId
我的报告工作正常但是当我要用pdf或word导出报告时,它会询问我参数和数据库登录的价值。
图片1
所以,我已经尽可能地从我的网站上解释过了。 我怎么能解决它? 并提前感谢。
答案 0 :(得分:1)
我看到您正确放置了登录信息,因此问题可能是您没有缓存您的crystalreport对象。
您需要缓存对象并在网页的Page_Init网络方法中再次绑定它。如果您要在报告中有多个页面,并且在导出时我认为这是必要的。
此文档中的更多信息:http://help.sap.com/businessobject/product_guides/sapCRVS2010/en/crnet13_sp14_dg_en.pdf
第56页(第1.3.3.4节),例如。