Data Connectivity
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Data Connectivity
Message Icon Topic: Runtime Connection to the Database server Post Reply Post New Topic
Author Message
Sreenivas
Newbie
Newbie


Joined: 21 Dec 2006
Location: India
Online Status: Offline
Posts: 1
Quote Sreenivas Replybullet Topic: Runtime Connection to the Database server
    Posted: 21 Dec 2006 at 4:33am
Hi,
 
Problem: Unable to Connect to Database at Runtime.
 
Reports are Created using a particular Database server and if we want to
change the database server still it connects to the previous database server only.  We would like to know how to connect to the other Database server having the same structure as of the initial one. We are using OLE DB (ADO) for the connection purpose. The Below given code is also used at the time of reports creation.
 
Code:

public void CrystalReportlogin(ReportDocument report)
{
ConnectionInfo connection = new CrystalDecisions.Shared.ConnectionInfo();
CrystalDecisions.Shared.TableLogOnInfo log = new
CrystalDecisions.Shared.TableLogOnInfo();
connection.DatabaseName =
ConfigurationManager.AppSettings["DataBaseName"].ToString();
connection.ServerName =
ConfigurationManager.AppSettings["ServerName"].ToString();
connection.UserID = ConfigurationManager.AppSettings["UserID"].ToString();
connection.Password =
ConfigurationManager.AppSettings["Password"].ToString();
foreach (CrystalDecisions.CrystalReports.Engine.Table tbl in
report.Database.Tables)
{
log = tbl.LogOnInfo;
log.ConnectionInfo = connection;
crvBlocksReceivedForTheMonth.LogOnInfo.Add(log);
}
}
 
Thanks & Regards,
Sreenivas Kaushik
S Kaushik
IP IP Logged
LeMike
Newbie
Newbie
Avatar

Joined: 18 Dec 2006
Online Status: Offline
Posts: 5
Quote LeMike Replybullet Posted: 23 Dec 2006 at 10:28am
I suppose that you have actually checked that

ConfigurationManager.AppSettings["ServerName"].ToString();

is really giving you what you are expecting ..... ?  (Yes, silly question ... I know ... I hope !)
It's not because things are hard that we don't try them ... it's because we don't try them that they are hard. (Lucius Seneca)
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.