生成水日报表
private void toolStripButton1_Click(object sender, EventArgs e)
{
ReportDocument doc = new ReportDocument();
doc.Load("CrystalReport1.rpt");
TableLogOnInfo tableLogOnInfo = new TableLogOnInfo();
tableLogOnInfo.ConnectionInfo.ServerName = "*.128.99.*";
tableLogOnInfo.ConnectionInfo.DatabaseName = "db";
tableLogOnInfo.ConnectionInfo.UserID = "sa";
tableLogOnInfo.ConnectionInfo.Password = "111111";
doc.Database.Tables[0].ApplyLogOnInfo(tableLogOnInfo);
crystalReportViewer1.ReportSource = doc;
}
另一种:
CrystalReport3 rpt = new CrystalReport3();
TableLogOnInfo info = new TableLogOnInfo();
TableLogOnInfos infos = new TableLogOnInfos();
ConnectionInfo conn = new ConnectionInfo();
conn.ServerName = ".";
conn.DatabaseName = "SilverGlobe";
conn.UserID = "sa";
conn.Password = "111111";
info.ConnectionInfo = conn;
info.TableName = "Companys";
infos.Add(info);
this.crystalReportViewer1.LogOnInfo = infos;
this.crystalReportViewer1.ReportSource = rpt;