I am using crystal report in
vb.net. i have build the crystal report ItemList.rpt. while design mode i have select SQL Server "ABC" as provider for the report and MYDatabase1 as source for he report. I have designed the report and if run through application, it works fine. Now I want to change the server name & database name for this crystal report file. for this i have used following code ..
Dim LogOnInfo As New CrystalDecisions.Shared.TableLogOnInfo()
Dim connectionInfo As New CrystalDecisions.Shared.ConnectionInfo()
Dim table As CrystalDecisions.CrystalReports.Engine.Table
Dim sItemList as new rptItemList ' this is report file instance
For Each table In sItemList.Database.Tables
LogOnInfo = table.LogOnInfo
' Set the server or ODBC data source name, database name,
' user ID, and password.
LogOnInfo.ConnectionInfo.ServerName = "XYZ"
LogOnInfo.ConnectionInfo.DatabaseName = "NewDatabase"
LogOnInfo.ConnectionInfo.UserID = "sa"
LogOnInfo.ConnectionInfo.Password = ""
' Apply the connection information to the table.
table.ApplyLogOnInfo(LogOnInfo)
Next table
sItemList.Refresh()
cr1.ReportSource = sItemList
After this if I check the logon info as ServerName, Database is changed to the newly assigned values, but the item list is shown from the ABC Servber's MyDatabase (from Database at design time.)
Can u solve this problem or suggest another method to perform this task please inform me
[email protected]
Maheshkumar Jadhav