A crystal report consists information of tables in a database. Each table can be attached to a different database, and hence you should set the database connection of each individual table
CrystalDecisions.CrystalReports.Engine.Table
The table property has a TableLogOnInfo Property which then has a connectionInfo property. Set this connection info property
CrystalDecisions.Shared.ConnectionInfo
you would need to set the datasource, database name, userid password if apllicable, etc
Thank you for the help. I tried using the idea to connect but I am not yet success. Please tell me what is wrong with this code bcus it fails to connect and I am prompted to provide the connection credentials.
/*
Note: I am using a passworded access database
(1) The code below fails to connect to the tables in the database and I don't know why.
(2) The second problem is the user id, what if someone logs in as a user other than Administrator?
*/
private void daily_report_frm_Load(object sender, System.EventArgs e)
{
//report object
date_report drpt=new date_report();
//inits
TableLogOnInfo logOnInfo = new TableLogOnInfo ();
int i = 0;
// Loop through every table in the report.
for (i=0;i == drpt.Database.Tables.Count - 1;i++)
{
// Set the connection information for the current table.
logOnInfo.ConnectionInfo.ServerName = "";
logOnInfo.ConnectionInfo.DatabaseName = "";
logOnInfo.ConnectionInfo.UserID = "Admin";
logOnInfo.ConnectionInfo.Password = "db_password";
drpt.Database.Tables [i].ApplyLogOnInfo (logOnInfo);
//test connectivity
MessageBox.Show(drpt.Database.Tables[i].TestConnectivity().ToString());
}
//report view
this.daily_report_viewer.ReportSource=drpt;
}