Solved

Changing DataSource

Posted on 2004-11-02
322 Views
Last Modified: 2008-01-16
I've a number of reports that are currently held on the local database server using OleDB ADO.

Now I need to be to tell each report, at run-time, to go get their data from an identical database but which is on a different server. What is the best way to do this ? Alternatively would it be better to keep a copy of the report locally on each server pointing at their own local database and load the reports remotely ?
Thanks
0
Question by:CliffordEvans
    12 Comments
     
    LVL 10

    Expert Comment

    by:ebolek
    you can write a small application and set  the db and server information runtime. If you need help with coding I can help you. what version crytsal, what language u can wriite app with you have to answer us first
    0
     

    Author Comment

    by:CliffordEvans
    Crystal 10
    VB.NET
    Thanks
    0
     
    LVL 10

    Expert Comment

    by:ebolek
    You dont like my c# codes though :)
    0
     
    LVL 100

    Expert Comment

    by:mlmcc
    0
     

    Author Comment

    by:CliffordEvans
    mlmcc - agree it is useful but can't find a relevant example.
    ebolek - C# is fine - I can convert it.
    0
     
    LVL 10

    Accepted Solution

    by:
    here you go

    internal static void SetConnection(ref ReportDocument report, string serverName, string databaseName)
                {
                      try
                      {
                            CrystalDecisions.Shared.TableLogOnInfo MyLogonInfo;
                            foreach(CrystalDecisions.CrystalReports.Engine.Table MyTable in report.Database.Tables)
                            {
                       
                                  MyLogonInfo = MyTable.LogOnInfo;
                                  if (MyTable.Name == "")
                                  {
                                        MyLogonInfo.ConnectionInfo.ServerName  = serverName;
                                        MyLogonInfo.ConnectionInfo.DatabaseName = databaseName;
                                        MyLogonInfo.ConnectionInfo.UserID = ""; //in integrated security, this is problem.
                                        MyLogonInfo.ConnectionInfo.Password  = "";      //it works when it is not changed
                                  }
                                  else
                                  {                  
                                  
                                         
                                        MyLogonInfo.ConnectionInfo.ServerName  = serverName;
                                        MyLogonInfo.ConnectionInfo.DatabaseName = databaseName;
                                        //MyLogonInfo.ConnectionInfo.AllowCustomConnection  = true;
                                        MyLogonInfo.ConnectionInfo.UserID  = "";
                                        MyLogonInfo.ConnectionInfo.Password = "";                              
                                         
                                  }
                                  MyTable.Location = MyTable.Location.Substring(MyTable.Location.LastIndexOf(".")+1);
                                  MyTable.ApplyLogOnInfo(MyLogonInfo);            
                                    
                            }                        
                      }
                      catch( Exception logonInfoException )
                      {
                            throw logonInfoException;
                      }
                }
                /// <summary>
                /// Gets the server name currently used in the application from the configuration manager  
                /// </summary>
                /// <returns></returns>
                ///
    0
     
    LVL 100

    Expert Comment

    by:mlmcc
    I don't have VB.Net so I haven't looked at that link in much detail.

    mlmcc
    0
     

    Author Comment

    by:CliffordEvans
    ebolek,
    Do have have code available to do this in VB6 too ?
    Thanks
    0
     

    Author Comment

    by:CliffordEvans
    Just realised it is very similar to .NET.
    0
     
    LVL 10

    Expert Comment

    by:ebolek
    I dont have vb code. Other experts might have it but the main iodea is the same. If you understand how to do it, it is a matter of time to write it in another language

    regards
    Emre
    0
     
    LVL 10

    Expert Comment

    by:ebolek
    Glad I could help

    Regards
    Emre
    0
     

    Author Comment

    by:CliffordEvans
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
    There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
    With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    931 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now