rickhodder
Programmer
I'm using VS2003 and Crystal Reports.NET
Despite the code below, my user is being prompted for the username and password for two tables (of the 12 in the report) one is a DataTable object called Images and one is a DataSet (the rest are sql server tables).
The server and database (but not the user or password ) are already populated for the sql server table, and the Images has no connection info (and it shouldnt since it is being set with SetDatasource)
Can anyone see what I'm doing wrong?
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);
}
}
}
Rick Hodder
MCP Visual Foxpro
C#, VB.NET Developer
Independent Consultant
MyBlog
Save to: Default
Switch color theme
Select message background color...
Select message area width...
Enable message width in percentage
Change toolbar background color...
Adjust message text font size...
Disable auto links
Enable acronyms
Disable message header
Disable auto quote
<B>Database logon</B> Thread #1109713 Message #1109713
Despite the code below, my user is being prompted for the username and password for two tables (of the 12 in the report) one is a DataTable object called Images and one is a DataSet (the rest are sql server tables).
The server and database (but not the user or password ) are already populated for the sql server table, and the Images has no connection info (and it shouldnt since it is being set with SetDatasource)
Can anyone see what I'm doing wrong?
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);
}
}
}
Rick Hodder
MCP Visual Foxpro
C#, VB.NET Developer
Independent Consultant
MyBlog
Save to: Default
Switch color theme
Select message background color...
Select message area width...
Enable message width in percentage
Change toolbar background color...
Adjust message text font size...
Disable auto links
Enable acronyms
Disable message header
Disable auto quote
<B>Database logon</B> Thread #1109713 Message #1109713