Wrox Programmer Forums
|
BOOK: Professional Crystal Reports for VS.NET
This is the forum to discuss the Wrox book Professional Crystal Reports for Visual Studio .NET by David McAmis; ISBN: 9780764544033
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Crystal Reports for VS.NET 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 January 20th, 2005, 05:43 AM
Registered User
 
Join Date: Jan 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Passing Database Logon Info

On p123 of 2nd edition, it describes how to pass logon info to a report.

1. Firstly, I have converted the code to c# (please see below - is it correct)

2. So I created a report using OLD DB(ADO), which is my prefered method of connection, and used the c# code. Nothing changed. The report was run, connected to database1 and used only 1 table being vat, just as if I did not have the code. What I wanted to do was run the same report against database2 which also has a vat table.

But the report simply printed out data from database1.

3. I then created a report using ODBC(RDO). This time, I get a database login screen. It shows it is against table vat and then asks for server name (which is set to (local)), database which is blank and nothing appears in the dropdown, login id of sa and blank password. Even if I type in here either database1 or 2, I get login failed.

If I do not include the code the report just works off database1.

4. here is c# code

CrystalReport3 myReport = new CrystalReport3();

CrystalDecisions.Shared.TableLogOnInfos myTableLogonInfos = new CrystalDecisions.Shared.TableLogOnInfos();
CrystalDecisions.Shared.TableLogOnInfo myTableLogonInfo = new CrystalDecisions.Shared.TableLogOnInfo();
CrystalDecisions.Shared.ConnectionInfo myConnectionInfo = new CrystalDecisions.Shared.ConnectionInfo();

myConnectionInfo.ServerName = "(local)";
myConnectionInfo.DatabaseName = "database2";
myConnectionInfo.UserID = "sa";
myConnectionInfo.Password = "";

myTableLogonInfo.ConnectionInfo = myConnectionInfo;
myTableLogonInfo.TableName = "vat";
myTableLogonInfos.Add(myTableLogonInfo);

crystalReportViewer1.LogOnInfo = myTableLogonInfos;

crystalReportViewer1.ReportSource = myReport;

5. Also, what would the foreach code look like?

 
Old February 14th, 2005, 08:48 AM
Registered User
 
Join Date: Feb 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try This :

Database crDatabase;
Tables crTables;
TableLogOnInfo crTableLogOnInfo;
ConnectionInfo crConnectionInfo;

crConnectionInfo = new ConnectionInfo();
crConnectionInfo.ServerName= ServerName;
crConnectionInfo.DatabaseName = DatabaseName
crConnectionInfo.UserID = UserName;
crConnectionInfo.Password = Password;

crDatabase = CRObject.Database;
crTables = crDatabase.Tables;

foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)
{
    crTableLogOnInfo = crTable.LogOnInfo;
    crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
    crTable.ApplyLogOnInfo(crTableLogOnInfo);
}

-vasanti






Similar Threads
Thread Thread Starter Forum Replies Last Post
Help passing login info to new page peterh Classic ASP Basics 4 January 10th, 2008 12:39 PM
Passing NT Login Info negrette Classic ASP Professional 1 October 25th, 2004 02:37 PM
Passing logon info sandeep Crystal Reports 1 October 6th, 2004 08:41 AM
Passing info between assemblies & projects BSkelding VB.NET 2002/2003 Basics 15 August 18th, 2004 08:25 AM





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