Print Page | Close Window

Change Server at run time

Printed From: Crystal Reports Book
Category: Crystal Reports for Visual Studio 2005 and Newer
Forum Name: Writing Code
Forum Discription: .NET programming API, report integration
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=6217
Printed Date: 14 May 2024 at 11:03pm


Topic: Change Server at run time
Posted By: snufse
Subject: Change Server at run time
Date Posted: 29 Apr 2009 at 1:04pm
We have an app where user selects a site code. Remote sites have the same data base name but the server name is diffrenet. Using crystal report viewer to show report. Now, how can a dynamically change server name at run time?
 
Can I do something like this?
 

Try

Dim myTable As CrystalDecisions.CrystalReports.Engine.Table

Dim myLogin As CrystalDecisions.Shared.TableLogOnInfo

myCrystalReport1.Load(myPath)

For Each myTable In myCrystalReport1.Database.Tables

myLogin = myTable.LogOnInfo

myLogin.ConnectionInfo.ServerName = myAdsIPAdress

myLogin.ConnectionInfo.DatabaseName = "C:\Program Files\Astec Industries\WM2000\Data\WM2000DATA.add"

myLogin.ConnectionInfo.UserID = "xxx"

myLogin.ConnectionInfo.Password = "yyy"

myTable.ApplyLogOnInfo(myLogin)

Next

myCrystalReport1.SetParameterValue("Ask-Date", DropDownList2.SelectedValue)

CrystalReportViewer1.ReportSource = myCrystalReport1

CrystalReportViewer1.Zoom(90)




Print Page | Close Window