private void SetDatabaseLogons(string sUser,string sPassword,string sServer,string sDatabase) { //First set logon of top reports this.oReport.SetDatabaseLogon(sUser,sPassword,sServer,sDatabase); ApplyDatabaseLogons(this.oReport,sUser,sPassword,sServer,sDatabase); //Now do subreports if(alSubReports.Count>0) { ReportDocument oSubReport; foreach(string sSubReportName in this.alSubReports) { // Subreport names are case sensitive!!!!!! Be careful oSubReport = this.oReport.OpenSubreport(sSubReportName); ApplyDatabaseLogons(oSubReport,sUser,sPassword,sServer,sDatabase); } } } private void ApplyDatabaseLogons(ReportDocument oRpt, string sUser,string sPassword,string sServer,string sDatabase) { this.oReport.SetDatabaseLogon(sUser,sPassword,sServer,sDatabase) ConnectionInfo oConnectionInfo= new ConnectionInfo(); oConnectionInfo.ServerName=sServer; oConnectionInfo.DatabaseName=sDatabase; oConnectionInfo.UserID=sUser; oConnectionInfo.Password=sPassword; TableLogOnInfo oTableLogon ; foreach(Table oT in oRpt.Database.Tables) { if(oT.Name.ToUpper()!="SEARCH" &&oT.Name.ToUpper()!="IMAGES" ) { oTableLogon=oT.LogOnInfo; oTableLogon.ConnectionInfo=oConnectionInfo; oT.ApplyLogOnInfo(oTableLogon); } else { if(oT.Name.ToUpper()=="SEARCH") { oT.SetDataSource(this.oSearch ); } if(oT.Name.ToUpper()=="IMAGES" ) { oT.SetDataSource(this.Images); } } }