Crystal Report in runtime

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can i use Crystal repors without knowing which database and table will be
used.
For example after any SQL query?
thanks
 
Base your Crystal report on a dataset. At runtime, you can use any data set
that is properly populated. You ill need to include code to tell the the
report how to talk to the new database, e.g.
sda.Fill(dsRpt,"ach_log");
AchLogEntry oRpt = new AchLogEntry() ;

//Boilerplate possibly required to change databases.
Database d ;
Tables c;
Table t ;
TableLogOnInfo ti = new TableLogOnInfo() ;
ConnectionInfo ci = new ConnectionInfo() ;
ci.ServerName = LoginPW.Server ;
ci.DatabaseName = LoginPW.Database;
ci.UserID = LoginPW.LoginID;
ci.Password = LoginPW.Password;
d = oRpt.Database ;
c = d.Tables ;
for (int i=0; i<c.Count; i++)
{
t = c ;
ti = t.LogOnInfo ;
ti.ConnectionInfo = ci ;
t.ApplyLogOnInfo(ti) ;
string s = LoginPW.Database+".dbo." +
t.Location.Substring(t.Location.LastIndexOf(".")+1) ;
t.Location = s;
}

oRpt.SetDataSource(dsRpt) ;
crViewer.ReportSource = oRpt ;
 
Hi,

Use the push method, simply is using a dataset as the datasource, now the
only trick is that you need the dataset schema before create the report ,
just run your SP dump it in a dataset and write the schema
later you browse for this file in the CR designer, later at runtime you do a
ReportDocument.SetDataSource( theDataSet);

cheers,
 
Back
Top