這是我的代碼,當我打開我的水晶報告時,它總是給我一個需要填寫用戶名和密碼的表單。我想禁用它。另一個問題是,當我在我的計算機中安裝我的項目時,我的項目正常運行,但仍然需要填寫用戶和密碼,並且如果我安裝到網絡或其他計算機上,當我在本地主機中填寫相同的用戶和密碼時,一個錯誤。如何將我的水晶報告連接到網絡
私人小組AssignConnection(BYVAL RPT作爲的ReportDocument) 昏暗的連接作爲新ConnectionInfo()
connection.DatabaseName = "pcba_info"
connection.ServerName = "192.168.0.201"
connection.UserID = "partschecker"
connection.Password = "sgic"
For Each table As CrystalDecisions.CrystalReports.Engine.Table In rpt.Database.Tables
AssignTableConnection(table, connection)
Next
' Now loop through all the sections and its objects to do the same for the subreports
'
For Each section As CrystalDecisions.CrystalReports.Engine.Section In rpt.ReportDefinition.Sections
' In each section we need to loop through all the reporting objects
For Each reportObject As CrystalDecisions.CrystalReports.Engine.ReportObject In section.ReportObjects
If reportObject.Kind = ReportObjectKind.SubreportObject Then
Dim subReport As SubreportObject = DirectCast(reportObject, SubreportObject)
Dim subDocument As ReportDocument = subReport.OpenSubreport(subReport.SubreportName)
For Each table As CrystalDecisions.CrystalReports.Engine.Table In subDocument.Database.Tables
AssignTableConnection(table, connection)
Next
subDocument.SetDatabaseLogon(connection.UserID, connection.Password, connection.ServerName, connection.DatabaseName)
End If
Next
Next
rpt.SetDatabaseLogon(connection.UserID, connection.Password, connection.ServerName, connection.DatabaseName)
End Sub
Private Sub AssignTableConnection(ByVal table As CrystalDecisions.CrystalReports.Engine.Table, ByVal connection As ConnectionInfo)
' Cache the logon info block
Dim logOnInfo As TableLogOnInfo = table.LogOnInfo
connection.Type = logOnInfo.ConnectionInfo.Type
' Set the connection
logOnInfo.ConnectionInfo = connection
' Apply the connection to the table!
table.LogOnInfo.ConnectionInfo.DatabaseName = connection.DatabaseName
table.LogOnInfo.ConnectionInfo.ServerName = connection.ServerName
table.LogOnInfo.ConnectionInfo.UserID = connection.UserID
table.LogOnInfo.ConnectionInfo.Password = connection.Password
table.LogOnInfo.ConnectionInfo.Type = connection.Type
table.ApplyLogOnInfo(logOnInfo)
End Sub
你可能會更具體一些c你想做什麼? 「網絡」在這種情況下沒有意義。 – user2721815
對不起,我編輯了我的評論。你能幫我嗎? – user3336059