"Bruce Wood" <br*******@canada.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
If I were you I would use Crystal Reports.
That said, there are two ways to use CR. One is the way that Ignacio
mentioned: the "push" model. Put your data in a DataSet, and push your
DataSet at CR by calling ReportDocument.SetDataSource(). The other way
is to write your invoice to a database (which maybe you were going to
do anyway) and then write a Crystal report that knows how to get the
invoice information back out of the database and report it.
We do things the first way (the way that Ignacio suggested). It's a bit
tricky, but once you get it figured out it works OK.
However, if you're using a database, the second way may be superior.
It's the more "usual" way of using CR, and CR tends to behave better
when used as a "pull" reporting tool rather than accepting a "push". As
well, it serves as a confirmation that you have, in fact, committed the
invoice information to the database. No commit, no report.
Hi,
Regarding accesing the DB directly you should always set the connection info
using code, put the DB info in the config file and use the code below to
make sure you don't get a nasty popup ( or an Exception) asking for the
connection info. Notice that you need to set this info to all the tables of
the report:
TableLogOnInfos crTableLogonInfos = new TableLogOnInfos();
ReportDocument reportDocument1 = new OpenRecords(); //this is the
report
ConnectionInfo crConnectionInfo = new ConnectionInfo();
crConnectionInfo.ServerName =
System.Configuration.ConfigurationSettings.AppSett ings["Server"];
crConnectionInfo.DatabaseName =
System.Configuration.ConfigurationSettings.AppSett ings["DataBase"] ;
crConnectionInfo.UserID =
System.Configuration.ConfigurationSettings.AppSett ings["User"] ;
crConnectionInfo.Password =
System.Configuration.ConfigurationSettings.AppSett ings["Password"] ;
foreach (CrystalDecisions.CrystalReports.Engine.Table table in
reportDocument1.Database.Tables)
{
TableLogOnInfo crTableLogonInfo = new TableLogOnInfo();
crTableLogonInfo.TableName = table.Name;
crTableLogonInfo.ConnectionInfo = crConnectionInfo;
crTableLogonInfos.Add( crTableLogonInfo);
table.ApplyLogOnInfo( crTableLogonInfo);
}
CrystalReportViewer1.LogOnInfo = crTableLogonInfos;
CrystalReportViewer1.ReportSource = reportDocument1;
cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation