Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Database logon
Message
 
 
To
All
General information
Forum:
ASP.NET
Category:
Reporting
Title:
Database logon
Miscellaneous
Thread ID:
01109713
Message ID:
01109713
Views:
60
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 SQL Server table (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
www.RickHodder.com
MyBlog
Next
Reply
Map
View

Click here to load this message in the networking platform