473,396 Members | 1,915 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Crystal Report log into two databases

Hello. I have been trying to log onto two databases at run time for a crystal report. I have tried both the crystal report viewer and the report document object viewer. I have no figured out a way to make it possible.

The code for the report document object viewer is below (with the server, password and user not included for both databases). It gives me an error saying that it cannot find the employee table (which is in the EmployeeTrack database).

Expand|Select|Wrap|Line Numbers
  1. protected void Page_Init(object sender, EventArgs e)
  2.     {
  3.         ConfigureCrystalReports();
  4.     }
  5.     private void ConfigureCrystalReports()
  6.     {
  7.         //string fieldUniqueID = Request.QueryString["UniqueID"];
  8.         //string fieldParID= Request.QueryString["ParID"];
  9.  
  10.        string fieldUniqueID = "100252";
  11.        string fieldParID = "1";
  12.  
  13.         ConnectionInfo connectionEmployee = new ConnectionInfo();
  14.         connectionEmployee.ServerName = "***************";
  15.         connectionEmployee.DatabaseName = "EmployeeTrack";
  16.         connectionEmployee.UserID = "***";
  17.         connectionEmployee.Password = "******";
  18.  
  19.         ConnectionInfo connectionPAR = new ConnectionInfo();
  20.         connectionPAR.ServerName = "********";
  21.         connectionPAR.DatabaseName = "PAR";
  22.         connectionPAR.UserID = "****";
  23.         connectionPAR.Password = "*****";
  24.  
  25.         reportSeparation = new ReportDocument();
  26.         string reportPath = Server.MapPath("Separation_Report_Local.rpt");
  27.         reportSeparation.Load(reportPath);
  28.  
  29.        SetDBLogonForReport(connectionEmployee, reportSeparation);
  30.        SetDBLogonForReport(connectionPAR, reportSeparation);
  31.  
  32.         SetCurrentValuesForParameterFieldUniqueID(reportSeparation, fieldUniqueID);
  33.         SetCurrentValuesForParameterFieldParID(reportSeparation, fieldParID);
  34.  
  35.         crystalReportViewer.ReportSource = reportSeparation;
  36.     }
  37.     private void SetCurrentValuesForParameterFieldUniqueID(ReportDocument reportDocument, String field)
  38.     {
  39.         ParameterValues currentParameterValues = new ParameterValues();
  40.         ParameterDiscreteValue parameterDiscreteValue = new ParameterDiscreteValue();
  41.         parameterDiscreteValue.Value = field;
  42.         currentParameterValues.Add(parameterDiscreteValue);
  43.  
  44.         ParameterFieldDefinitions parameterFieldDefinitions = reportDocument.DataDefinition.ParameterFields;
  45.         ParameterFieldDefinition parameterFieldDefinition = parameterFieldDefinitions[PARAMETER_FIELD_UNIQUE];
  46.         parameterFieldDefinition.ApplyCurrentValues(currentParameterValues);
  47.     }
  48.     private void SetCurrentValuesForParameterFieldParID(ReportDocument reportDocument, String field)
  49.     {
  50.         ParameterValues currentParameterValues = new ParameterValues();
  51.         ParameterDiscreteValue parameterDiscreteValue = new ParameterDiscreteValue();
  52.         parameterDiscreteValue.Value = field;
  53.         currentParameterValues.Add(parameterDiscreteValue);
  54.  
  55.         ParameterFieldDefinitions parameterFieldDefinitions = reportDocument.DataDefinition.ParameterFields;
  56.         ParameterFieldDefinition parameterFieldDefinition = parameterFieldDefinitions[PARAMETER_FIELD_PAR];
  57.         parameterFieldDefinition.ApplyCurrentValues(currentParameterValues);
  58.     }
  59.     private void SetDBLogonForReport(ConnectionInfo connectionInfo, ReportDocument reportDocument)
  60.     {
  61.         Tables tables = reportDocument.Database.Tables;
  62.         foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
  63.         {
  64.             TableLogOnInfo tableLogonInfo = table.LogOnInfo;
  65.             tableLogonInfo.ConnectionInfo = connectionInfo;
  66.             table.ApplyLogOnInfo(tableLogonInfo);
  67.         }
  68.     }
  69. }
  70.  
  71.  
My code for crystal report viewer is below. I just have to fill in the password for one of the databases with the code below. The log in window for only one of the databases shows up.

Expand|Select|Wrap|Line Numbers
  1.  
  2. private const string PARAMETER_FIELD_UNIQUE = "UniqueID";
  3.     private const string PARAMETER_FIELD_PAR = "ParID";
  4.  
  5.  
  6.     protected void Page_Init(object sender, EventArgs e)
  7.     {
  8.         ConfigureCrystalReports();
  9.     }
  10.  
  11.     private void ConfigureCrystalReports()
  12.     {
  13.        string fieldUniqueID = Request.QueryString["UniqueID"];
  14.       string fieldParID = Request.QueryString["ParID"];
  15.  
  16.       //string fieldUniqueID = "100028";
  17.       // string fieldParID = "14";
  18.  
  19.         ConnectionInfo connectionEmployee = new ConnectionInfo();
  20.         connectionEmployee.ServerName = "********";
  21.         connectionEmployee.DatabaseName = "EmployeeTrack";
  22.         connectionEmployee.UserID = "****";
  23.         connectionEmployee.Password = "********";
  24.  
  25.         ConnectionInfo connectionPAR = new ConnectionInfo();
  26.         connectionPAR.ServerName = "***********";
  27.         connectionPAR.DatabaseName = "PAR";
  28.         connectionPAR.UserID = "*******";
  29.         connectionPAR.Password = "*********";
  30.  
  31.         string reportPath = Server.MapPath("PAR_Report_Local.rpt");
  32.         crystalReportViewer.ReportSource = reportPath;
  33.  
  34.         SetDBLogonForReport(connectionEmployee);
  35.         SetDBLogonForReport(connectionPAR);
  36.  
  37.  
  38.         SetCurrentValuesForParameterFieldUnique(parameterFields, fieldUniqueID);
  39.         SetCurrentValuesForParameterFieldPAR(parameterFields, fieldParID);
  40.  
  41.     }
  42.     private void SetCurrentValuesForParameterFieldUnique(ParameterFields parameterFields, String field)
  43.     {
  44.         ParameterValues currentParameterValues = new ParameterValues();
  45.  
  46.         ParameterDiscreteValue parameterDiscreteValue = new ParameterDiscreteValue();
  47.         parameterDiscreteValue.Value = field;
  48.         currentParameterValues.Add(parameterDiscreteValue);
  49.  
  50.  
  51.         ParameterField parameterField = parameterFields[PARAMETER_FIELD_UNIQUE];
  52.         parameterField.CurrentValues = currentParameterValues;
  53.  
  54.     }
  55.     private void SetCurrentValuesForParameterFieldPAR(ParameterFields parameterFields, String field)
  56.     {
  57.         ParameterValues currentParameterValues = new ParameterValues();
  58.  
  59.         ParameterDiscreteValue parameterDiscreteValue = new ParameterDiscreteValue();
  60.         parameterDiscreteValue.Value = field;
  61.         currentParameterValues.Add(parameterDiscreteValue);
  62.  
  63.  
  64.         ParameterField parameterField = parameterFields[PARAMETER_FIELD_PAR];
  65.         parameterField.CurrentValues = currentParameterValues;
  66.  
  67.     }
  68.  
  69.     private void SetDBLogonForReport(ConnectionInfo connectionInfo)
  70.     {
  71.         TableLogOnInfos tableLogOnInfos = crystalReportViewer.LogOnInfo;
  72.         foreach (TableLogOnInfo tableLogOnInfo in tableLogOnInfos)
  73.         {
  74.             tableLogOnInfo.ConnectionInfo = connectionInfo;
  75.         }
  76.     }
  77. }
  78.  
  79.  
Any help would be greatly appreciated. Thanks.

-Michelle
Aug 7 '07 #1
0 1571

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: kristoff plasun | last post by:
I have a problem with a C++ DCOM application that prints Crystal Reports with data from Oracle. The SQL query is relatively complex but when the report is printed from the Crystal Reports...
2
by: Tim Burda | last post by:
I posted this in another forum, but I'm adding it here to for more exposure.I am using Visual Studio 2003 and trying to get Crystal Reports to produce output. If you have any ideas, please let me...
3
by: oscar | last post by:
is there a way of integrating mysql databases into the .net crystal reports? in the report wizard i have options for sql databases, but nothing for mysql. is there a plugin i'm missing for it? ...
2
by: airkart | last post by:
Hello, I've scoured groups and the web, and haven't found a question like mine answered. I'm using Visual Studio 2003 with the Crystal Reports it comes bundled with and SQL Server 2000....
6
by: Robin Cushman | last post by:
Hi all, I need some help -- I'm working with an A2K database, using DAO, and am trying to read records into a Crystal Report and then export it to a folder on our network as an Excel...
0
by: Atif | last post by:
Hi All My problem is not related with this group BUT i have got a clue from here that's why i am posting this question over here. I am using Crystal Reports 9 with MySQL and SQL Server....
2
by: aldous scotch | last post by:
I designed a Crystal Report .rpt from within Microsoft Development Environment 2003 Version 7.1.3088 (VB .NET IDE). I selected database fields from the left side Field Explorer onto the Details...
5
by: jmar | last post by:
I posted a week ago and received one response. I'm looking for the opinion of several experienced .NET people before I proceed so I'm posting again. Sorry for the repost... I am updating a...
0
by: bharathi228 | last post by:
hello in my application we hav monthly databases every month we create new database through code in asp.net database name like 200901AVG 200902AVG now my problem is iam...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.