Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > Crystal Reports
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 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
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old September 26th, 2003, 08:38 AM
Registered User
 
Join Date: Sep 2003
Location: pretoria, gauteng, South Africa.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default creating dynamic reports for different databases

Hi.

I want to be able to create dynamic reports for different databases.

By that I mean... I want the user to enter the servername,databasename,userid, password and this gets read in and this is the info that connects the .net application to the database.
Then, with this info being connected to the database, I want to be able from the crystal report(.rpt) be able to extract the necessary table info without having to go through the DB connection wizard on the report!

Can someone advise me on this?:(
Reply With Quote
  #2 (permalink)  
Old September 27th, 2003, 12:42 AM
Registered User
 
Join Date: Sep 2003
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ok there are two models that .Net provides.
one is Pull Model and other is Push Model.
Pull Model is one which u used to Connect ur report through wizard.
push is little bit complex but provides great flexbility. so firts create Dataset, populate it with data from database manuulay(through coding) an then assign this dataset object to ur report datasource property. ur report object will automatically exract rows from it.



Reply With Quote
  #3 (permalink)  
Old September 27th, 2003, 01:52 AM
Friend of Wrox
Points: 3,558, Level: 25
Points: 3,558, Level: 25 Points: 3,558, Level: 25 Points: 3,558, Level: 25
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: California, USA
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik Send a message via Skype™ to melvik
Default

Dear friend:
I guess there is no hard part on this topic if u know what u'll do!
well, first u need a form to get User & server & ... info that u need from user. so then u'll pass those to ur report page & connect to ...
im going to send u a sample & hope it wull help u to connect to DB.

let me know what u've done.
Code:
    public class showreps : System.Web.UI.Page
    {

        //CR Variables
        Empower.reports.foreign        crReportft;
        Empower.reports.foreign_p    crReportfb;
        ConnectionInfo crConnectionInfo;
        TableLogOnInfo crTableLogOnInfo;
        Database crDatabase;
        Tables crTables;
        ParameterFields crParameterFields;
        ParameterField crParameterField;
        ParameterValues crParameterValues;
        ParameterDiscreteValue crParameterDiscreteValue;
        protected CrystalDecisions.Web.CrystalReportViewer CrystalReportViewer1;
        protected CrystalDecisions.Web.CrystalReportViewer CrystalReportViewer2;

        private void Page_Load(object sender, System.EventArgs e)
        {
            string id, type;
                    id = Request.QueryString.Get("id");

                    crReportft = new Empower.reports.foreign();
                    crConnectionInfo = new ConnectionInfo();
                    crConnectionInfo.ServerName = "BORNA";
                    crConnectionInfo.DatabaseName = "NewBaz";
                    crConnectionInfo.UserID = "report";
                    crConnectionInfo.Password = "";

                    crDatabase = crReportft.Database;
                    crTables = crDatabase.Tables;

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

                    crReportfb = new Empower.reports.foreign_p();
                    crConnectionInfo = new ConnectionInfo();
                    crConnectionInfo.ServerName = "BORNA";
                    crConnectionInfo.DatabaseName = "NewBaz";
                    crConnectionInfo.UserID = "report";
                    crConnectionInfo.Password = "";

                    crDatabase = crReportfb.Database;
                    crTables = crDatabase.Tables;

                    foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)
                    {        
                        crTableLogOnInfo = crTable.LogOnInfo;
                        crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
                        crTable.ApplyLogOnInfo(crTableLogOnInfo);
                    }
                CrystalReportViewer1.ReportSource = crReportft;
                CrystalReportViewer2.ReportSource = crReportfb;
        }
    }
Always:),
Hovik Melkomian.
Reply With Quote
Reply


Thread Tools
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
Dynamic Reports mirabilis C# 0 July 18th, 2005 09:07 AM
Reports for two different databases using ODBC nfg Crystal Reports 0 July 5th, 2005 08:17 AM
VB databases and Reports samnikh VB Databases Basics 1 July 4th, 2005 01:32 AM
Dynamic Reports dhimank Crystal Reports 3 May 10th, 2005 03:13 AM
Can Crystal Reports query across databases? meltias Crystal Reports 1 May 12th, 2004 05:29 PM



All times are GMT -4. The time now is 12:13 AM.


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