Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LogonInfo is not changing using this code for reports

Status
Not open for further replies.

essa2000

Programmer
Dec 6, 2000
299
CA
I am using following code and I got this code from sample codes of microsoft but it is not changing the connectioninfo instead of using the same code.

--------------------------------------------------------
Private Sub btnPreviewBasicReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPreviewBasicReport.Click

' In this event the Ten Most Expensive Products Report is loaded
' and displayed in the crystal reports viewer.

' Objects used to set the proper database connection information
Dim tbCurrent As CrystalDecisions.CrystalReports.Engine.Table
Dim tliCurrent As CrystalDecisions.Shared.TableLogOnInfo

' Create a report document instance to hold the report
Dim rptExpensiveProducts As New ReportDocument()

Try
' Load the report
rptExpensiveProducts.Load("..\TenMostExpensiveProducts.rpt")

' Set the connection information for all the tables used in the report
' Leave UserID and Password blank for trusted connection
For Each tbCurrent In rptExpensiveProducts.Database.Tables
tliCurrent = tbCurrent.LogOnInfo
With tliCurrent.ConnectionInfo
.ServerName = "ServerName"
.UserID = ""
.Password = ""
.DatabaseName = "NorhtWind"

End With

tbCurrent.ApplyLogOnInfo(tliCurrent)

Next tbCurrent

' Set the report source for the crystal reports
' viewer to the report instance.

crvBasic.ReportSource = rptExpensiveProducts

' Zoom viewer to fit to the whole page so the user can see the report
crvBasic.Zoom(2)

Catch Exp As LoadSaveReportException
MsgBox("Incorrect path for loading report.", _
MsgBoxStyle.Critical, "Load Report Error")

Catch Exp As Exception
MsgBox(Exp.Message, MsgBoxStyle.Critical, "General Error")

End Try

End Sub
----------------------------------------------------------

I want to run this report using differnet Database name on differnet server , for example If I want to run this report on "ServerName2" and with database "NW" then I'll change the value of these parameter as follows


With tliCurrent.ConnectionInfo
.ServerName = "ServerName2"
.UserID = ""
.Password = ""
.DatabaseName = "NW"

End With

I did it but report is retreiving data from the previous connection info and showing data from "Northwind" instead of showing data from "NW" , Actually , the goal is I want to run my reports using different databases on different servers.

I've been doing R & D on it since long but now I am failed to get the solutions , can anyone solve my problem.

Thanks.


Muhammad Essa Mughal
Software Engineer
iLogic Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top