我已閱讀所有關於在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
我有一個從那裏我有三個字段1.沒有fromdate 2. TODATE 3.僱員
我報告工作正常,但是當我去出口用pdf或Word報告它向我詢問參數和數據庫登錄的價值。
圖像1
所以,我從SI解釋儘可能多的。 我怎麼解決它? 並提前致謝。
[如何停止水晶報表查看器在打開子報表時要求登錄憑據](http://stackoverflow.com/questions/21709438/how-to-stop-crystal-report-viewer-from-asking- login-credentials-when-opening-sub) –
torha matha sala,dekhos na upore ami likhsi je ai問題相關的問題,但我沒有得到任何幫助。 –