My first post here. I posted this question over in the ASP.NET forums that I usually frequent, but no one has been able to help me out. I ran across this site and thought perfect maybe there will be experts over here for my peculiar problem. Anyway here is the run down.
I've made a windows form project with Crystal Reports. I have two
machines one which I was working on and one which I was testing from.
The one I was working the project on has Visual Studio 2008 loaded.
The one I was testing from at one time has VS 2008 loaded, but no
longer has it. When I originally deployed my ClickOnce package I was
not including "Crystal Reports Basic for Visual Studio 2008" in the
package, but it didn't matter for my test machine. It still ran fine.
It wasn't until I went to a 3rd machine when I started getting errors
when trying to access a Crystal Report.
I was able to
realize that I needed to have "Crystal Reports Basic for Visual Studio"
included in the prerequisite components. Once I chose this option the
3rd machine then was able to view the Crystal Reports, but a new issue
came up. On this third machine now a database login prompt displays.
This was not an issue with the 2nd machine that I was originally used
for testing, but that 2nd machine at one time had VS 2008 loaded.
The
code for the report is to use integrated security. So once again I
code from machine 1 and debug mode it runs fine. I installed the
application with ClickOnce on machine 2 which once had VS 2008
installed, but no longer has VS 2008 installed and the Crystal Reports
run fine. I installed on a 3rd machine that never had any version of
Visual Studio installed on it and I can view the Crystal Viewer, but
now it is asking for a SQL server login prompt. I am going to
include the code below. Any advise would be greatly appreciated.
- public Z()
- {
- InitializeComponent();
-
- ReportDocument cryRpt = new ReportDocument();
- string RPTlocation = Constants.GetRPTlocation().ToString();
- cryRpt.Load(@RPTlocation + "z.rpt");
- //between coments was added to make database connection dynamic
- /////////////////////////////////////////////////////////////////
- TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
- TableLogOnInfo crtableLogininfo = new TableLogOnInfo();
- ConnectionInfo crConnectionInfo = new ConnectionInfo();
- Tables CrTables;
- //////////////////////////////////////////////////////////////////
-
-
-
- //between coments was added to make database connection dynamic
- //////////////////////////////////////////////////////////////////
- crConnectionInfo.ServerName = Constants.DevOrProduction.ToString() + "\\sql2";
- crConnectionInfo.DatabaseName = "Z";
- crConnectionInfo.IntegratedSecurity = true;
- CrTables = cryRpt.Database.Tables;
- foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
- {
- crtableLogininfo = CrTable.LogOnInfo;
- crtableLogininfo.ConnectionInfo = crConnectionInfo;
- CrTable.ApplyLogOnInfo(crtableLogininfo);
- }
- ///////////////////////////////////////////////////////////////////
-
- // Create parameter objects
- ParameterFields myParams = new ParameterFields();
- ParameterField myParam = new ParameterField();
- ParameterField myParam2 = new ParameterField();
- ParameterDiscreteValue myDiscreteValue = new ParameterDiscreteValue();
-
- // Set the ParameterFieldName to the name of the parameter
- // created in the Field Explorer
- myParam.ParameterFieldName = "mydate";
-
- // Add discrete values for the date
- DateTime mydate2 = DateTime.Parse(Constants.mydate);
- myDiscreteValue.Value = mydate2;
- myParam.CurrentValues.Add(myDiscreteValue);
-
- // Add param object to params collection
- myParams.Add(myParam);
-
- // Assign the params collection to the report viewer
- crystalReportViewer1.ParameterFieldInfo = myParams;
-
- // Assign the Report to the report viewer.
- crystalReportViewer1.ReportSource = cryRpt;
- //crystalReportViewer1.Refresh();
- //TRIED WITH ABOVE REFRESH ON AND OFF, MAKES NO DIFFERENCE
- //SAME DB LOGIN PROMPT
-
- this.WindowState = FormWindowState.Maximized;
- Constants.mydate = null;
- }