2011-04-07 82 views
1

我使用水晶報告創建了報告。我爲此使用了ado.net連接。我創建了一個數據集並加入了報告。再次詢問登錄信息

在編碼教職員

Dim Rpt As New ReportDocument 
Dim ClientAdp As New ClientTableAdapters.ClientsTableAdapter 
Dim ClientDt As New Client.ClientsDataTable 

ClientAdp.Connection = New SqlConnection(ConfigurationManager.ConnectionStrings("CurrentConnection").ConnectionString) 
ClientAdp.Fill(ClientDt) 

Rpt.Load(Server.MapPath(ADONET_REPORT_FILE)) 
Rpt.SetDataSource(CType(ClientDt, DataTable)) 
Rpt.SetDatabaseLogon("123", "123") 
ReportViewer.ReportSource = Rpt 

這是第一次加載時間確定。當我在報告視圖中單擊打印按鈕時,報告視圖詢問登錄信息。我該如何適應這個問題

回答

0

我認爲你需要爲報告中的每個表格設置TableLogOnInfo而不僅僅是報告。

Dim logOnInfo As TableLogOnInfo 
For Each tbCurrent As CrystalDecisions.CrystalReports.Engine.Table In Rpt.Database.Tables 
    logOnInfo = tbCurrent.LogOnInfo 
    logOnInfo.ConnectionInfo.DatabaseName = "MyDatabaseName" 
    logOnInfo.ConnectionInfo.UserID = "UserId" 
    logOnInfo.ConnectionInfo.Password = "secretpassword" 
    logOnInfo.ConnectionInfo.ServerName = "SQLServer" 
    logOnInfo.ConnectionInfo.Type = ConnectionInfoType.SQL 
    tbCurrent.ApplyLogOnInfo(logOnInfo) 
Next 

我有a blog post here詳述此完全(這是寫在C#中,但同樣的原則也適用於VB.NET)

+0

這是第一次負荷確定。當顯示報告時,我點擊報告按鈕。在這種情況下,報告視圖詢問登錄信息。 – zanhtet 2011-04-07 09:55:26