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 September 26th, 2003, 07:38 AM
Registered User
 
Join Date: Sep 2003
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?:(
 
Old September 26th, 2003, 11:42 PM
Registered User
 
Join Date: Sep 2003
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.



 
Old September 27th, 2003, 12:52 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

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.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic Reports mirabilis C# 0 July 18th, 2005 08:07 AM
Reports for two different databases using ODBC nfg Crystal Reports 0 July 5th, 2005 07:17 AM
VB databases and Reports samnikh VB Databases Basics 1 July 4th, 2005 12:32 AM
Dynamic Reports dhimank Crystal Reports 3 May 10th, 2005 02:13 AM
Can Crystal Reports query across databases? meltias Crystal Reports 1 May 12th, 2004 04:29 PM





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