Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Changing DataSource

Posted on 2004-11-02
12
Medium Priority
?
337 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
Comment
Question by:CliffordEvans
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
  • 2
12 Comments
 
LVL 10

Expert Comment

by:ebolek
ID: 12475612
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
ID: 12475639
Crystal 10
VB.NET
Thanks
0
 
LVL 10

Expert Comment

by:ebolek
ID: 12475665
You dont like my c# codes though :)
0
[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

 
LVL 101

Expert Comment

by:mlmcc
ID: 12475883
0
 

Author Comment

by:CliffordEvans
ID: 12476354
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:
ebolek earned 1600 total points
ID: 12476536
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 101

Expert Comment

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

mlmcc
0
 

Author Comment

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

Author Comment

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

Expert Comment

by:ebolek
ID: 12554893
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
ID: 12555085
Glad I could help

Regards
Emre
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Loops Section Overview
Suggested Courses

610 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