Print Page | Close Window

How to change database c# 2005

Printed From: Crystal Reports Book
Category: Crystal Reports for Visual Studio 2005 and Newer
Forum Name: Data Connectivity
Forum Discription: How to connect to data sources and export reports
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=1870
Printed Date: 02 May 2025 at 9:50pm


Topic: How to change database c# 2005
Posted By: Santiago
Subject: How to change database c# 2005
Date Posted: 11 Dec 2007 at 2:26pm

I have a report that is atched to a database (using a store procediture) I want to change the database connection at run time, but when I change the database the parameters are not passed and viseversa. Please help me with any idea. This is the code I am using: 

(C_App is the database name I want to set up, but everytime the report grabs the default database SM_App) 
 
 
 
ReportDocument myDataReport = new ReportDocument();

myDataReport.Load("C:\\Report.rpt");

CrystalDecisions.Shared.TableLogOnInfo myInfo;

crview.LogOnInfo = new TableLogOnInfos();

myInfo = new TableLogOnInfo();

myInfo.ConnectionInfo.ServerName = "DAtabaseName";

myInfo.ConnectionInfo.DatabaseName = "C_App";

myInfo.ConnectionInfo.UserID = "sa";

myInfo.ConnectionInfo.Password = "password";

myDataReport.SetParameterValue("@parameter1", "value1");

myDataReport.SetParameterValue("@parameter2", "value2");

 

CrystalReportViewer1.LogOnInfo.Add(myInfo);

CrystalReportViewer1.ReportSource = myDataReport;

}




Print Page | Close Window