471,605 Members | 1,609 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,605 software developers and data experts.

Crystal Report in runtime

MAT
How can i use Crystal repors without knowing which database and table will be
used.
For example after any SQL query?
thanks
Dec 20 '05 #1
2 1471
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[i] ;
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 ;

"MAT" wrote:
How can i use Crystal repors without knowing which database and table will be
used.
For example after any SQL query?
thanks

Dec 20 '05 #2
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,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"MAT" <MA*@discussions.microsoft.com> wrote in message
news:84**********************************@microsof t.com...
How can i use Crystal repors without knowing which database and table will
be
used.
For example after any SQL query?
thanks

Dec 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Stephan | last post: by
4 posts views Thread by Rick Thiel | last post: by
reply views Thread by Tim Jones | last post: by
reply views Thread by Dipendra | last post: by
reply views Thread by Timmy Jones | last post: by
11 posts views Thread by =?Utf-8?B?cmtibmFpcg==?= | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by CCCYYYY | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.