Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > Crystal Reports
|
Crystal Reports General discussion about Crystal Reports. For discussions specific to the book Professional Crystal Reports for VS.NET, please see the book discussion forum for that book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Crystal Reports section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 21st, 2004, 06:02 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 142
Thanks: 0
Thanked 2 Times in 2 Posts
Default Database logon problem with Crystal Report

I'm delivering a crystal report through an asp.net page, using the crystal report viewer. When testing on my machine, everything works ok, however when the page is loaded on any other machine the user is prompted to logon to the database.

I'm confused about this because I did have this problem on my own machine until I put the following line in to the setup code;

Code:
rpt.SetDatabaseLogon("dbLogon", "password")
(where rpt is the crystal report being used)

How do I overcome this problem; i.e. get the report to load without the user being prompted to log on to the database? The crystal report is one I developed outside of visual studio and then added to a project, so it sets up all it's own connections, etc. I'm using CR10

 
Old April 21st, 2004, 07:00 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

Plz take a look at http://p2p.wrox.com/topic.asp?TOPIC_ID=6389
u should login for every table u use in ur rpt file.
actually, im not sure about that & I'll be glad if there r better ways. (This was what I got from a sample in net & hope its the right way)

Always:),
Hovik Melkomian.
 
Old April 29th, 2004, 12:37 PM
Registered User
 
Join Date: Apr 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can create a File DSN for an ODBC connection, edit the file in notepad to add the password, and use this File DSN as you datasource.

jakemm
 
Old June 6th, 2004, 11:59 PM
Registered User
 
Join Date: Jun 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

use this code in crystalReportViewer.

//Create the ConnectionInfos object to store the database logon Information
ConnectionInfos connInfos = new ConnectionInfos();

//Create a ConnectionInfo object for each database logon you want to set.
IConnectionInfo connInfo1 = new ConnectionInfo();

//Set the database logon information for each ConnectionInfo object.
connInfo1.setUserName("Scott");
connInfo1.setPassword("Tiger");

//Add each ConnectionInfo object to the ConnectionInfos collection.
//The ConnectionInfos object can now be used to set the database logon information for a report.
connInfos.add(connInfo1);

//Set the database logon information by passing the viewer the initialized ConnectionInfos object.
viewer.setDatabaseLogonInfos(connInfos);
viewer.setEnableLogonPrompt(false);


 
Old June 24th, 2004, 04:23 AM
Registered User
 
Join Date: Jun 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi!
I've big problems with reports and data source.

1- I create a IConnectionInfo, with all properties I want.
2- my piece of code :
Code:
viewer.setReportSource(reportSource);
ConnectionInfos connInfos = viewer.getDatabaseLogonInfos();
connInfos.clear(); //I voluntarily delete all connection info associated
                   //with the report (at the design time).
System.out.println(connInfo.getAttributes().toString());
//It prints everything OK, with all the parameters I defined in my IConnectionInfo :)
connInfos.add(connInfo); //Add my IConnectionInfo to the collection

//Here comes the trouble...
viewer.setDatabaseLogonInfos(connInfos);
System.out.println(viewer.getDatabaseLogonInfos().getConnectionInfo(0).getAttributes().toString());
//Now it prints the infos that will be used for display.
//I hoped my changes infos, and I get the design-time infos !!!! :(
//So baaaad !

//and then viewer.refresh(), processHttpRequest() and dispose()...
I followed the tutorials/examples in the PDF "CR for JBuilder"... but nothing better happen :(

The collection connInfos is OK, cleared and then have my changed settings, but the view.setDatabaseLogonInfos doesn't work.

The System.err prints on setDatabaseLogonInfos. (I printed some ##### marks just before and after the instruction, and between them, there is nothing.

I'm really desperate! I really need to change the database logon informations because I've several databases and I want to use the same report.

 
Old October 25th, 2004, 02:32 AM
Registered User
 
Join Date: Jun 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I just tried with a new version.
That's not better :(

 
Old September 25th, 2009, 11:39 AM
Registered User
 
Join Date: Sep 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Not able to login to the crystal report

Hi, I am facing issue with the crystal report with dynamic databases.
Please let me brief the context here.

I have some crystal reprots (8.5) which uses ODBC to run. I am using the .Net winform to call each report. The server, database, user id and passwords are passed dynamically. But, some of the reports are failing to execute and say ".. Table not found .." error. To set the logon, I use the following code.

reportDoc.SetDatabaseLogon(userName, password, database, database);
foreach (IConnectionInfo conInfo in reportDoc.DataSourceConnections)
{
conInfo.SetConnection(serverName, database, userName, password);
}

foreach (CrystalDecisions.CrystalReports.Engine.Table table in reportDoc.Database.Tables)
{
TableLogOnInfo logOnInfo = table.LogOnInfo;
if (logOnInfo != null)
{
logOnInfo.TableName = table.Name;
logOnInfo.ConnectionInfo = connectionInfo;
table.ApplyLogOnInfo(logOnInfo);
table.Location = string.Format("{0}.dbo.{1}", database, table.Location.Substring(table.Location.LastIndexO f(".") + 1));
}
}

// Set subreport connection info
foreach (ReportDocument subreport in reportDoc.Subreports)
{
foreach (IConnectionInfo conInfo in reportDoc.DataSourceConnections)
{
conInfo.SetConnection(serverName, database, userName, password);
}
foreach (Table table in subreport.Database.Tables)
{
TableLogOnInfo logOnInfo = table.LogOnInfo;
if (logOnInfo != null)
{
logOnInfo.TableName = table.Name;
logOnInfo.ConnectionInfo = connectionInfo;
table.ApplyLogOnInfo(logOnInfo);
table.Location = string.Format("{0}.dbo.{1}", database, table.Location.Substring(table.Location.LastIndexO f(".") + 1));
}
}
}

But, even after setting this, some reports didnot executed. But i found a weired issue while debugging the code. The logon connection info is the default database set while developing the report, but while setting the connection, the database is set to "master"!!! This happens only for some of the reports. So i dont think this is a code issue.

Can anyone help on this?

Shyju





Similar Threads
Thread Thread Starter Forum Replies Last Post
Logon Problem using Crystal Report and Asp.net ??? charles Crystal Reports 13 March 1st, 2007 02:49 PM
logon error while exporting crystal report hotshot_21 Crystal Reports 0 February 28th, 2006 07:37 AM
Crystal Report Logon failed mrleaps ASP.NET 1.0 and 1.1 Professional 1 October 13th, 2005 01:06 PM
Database Logon Problem subhan Crystal Reports 3 September 24th, 2005 12:24 PM
Crystal Report: 20536: Unable to logon server caryraleigh Pro VB 6 0 December 4th, 2004 10:38 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.