Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 20th, 2005, 05:43 AM
Registered User
Join Date: Jan 2005
Location: , , .
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";

crystalReportViewer1.LogOnInfo = myTableLogonInfos;

crystalReportViewer1.ReportSource = myReport;

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

Reply With Quote
  #2 (permalink)  
Old February 14th, 2005, 08:48 AM
Registered User
Join Date: Feb 2005
Location: , , India.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts

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;


Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 10:57 AM.

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