正在研究CrystalReport,下面的代码为当sql server密码不为空时的写法

发表于:2007-06-30来源:作者:点击数: 标签:
ReportDocument rptDoc = new ReportDocument(); rptDoc.Load(x:\\crysta lr eport\\crPull.rpt); TableLogOnInfo logOnInfo = new TableLogOnInfo(); logOnInfo = rptDoc.Database.Tables[tblMagUserInfo].LogOnInfo; ConnectionInfo connectionInfo = new C
ReportDocument rptDoc = new ReportDocument();
            rptDoc.Load("x:\\crystalreport\\crPull.rpt");
            
            TableLogOnInfo logOnInfo = new TableLogOnInfo();
            logOnInfo = rptDoc.Database.Tables["tblMagUserInfo"].LogOnInfo;
            ConnectionInfo connectionInfo = new ConnectionInfo();
            connectionInfo = logOnInfo.ConnectionInfo;

            connectionInfo.ServerName = "myserver";
            connectionInfo.DatabaseName = "mydb";
            connectionInfo.UserID = "myid";
            connectionInfo.Password = "mypwd";

            rptDoc.Database.Tables["tblMagUserInfo"].ApplyLogOnInfo(logOnInfo);

            CrystalReportViewer1.ReportSource = rptDoc;

原文转自:http://www.ltesting.net