Skip to Content
0
Former Member
Jan 09, 2010 at 02:03 PM

Missing DataBase Login information for deployed VS2008 w/Crystal Report

42 Views

I'm creating a Windows Form application using VS2008 Pro and the basic Crystal Reports (included).</br></br>

I've successfully added a crystalreportviewer control and a crystal report (.rpt) to my form. I've written the following code in the code behind to programmatically load/bind the report to the viewer. Everything works fine on my development machine (or any machine that has Visual Studio installed). Where I'm encountering problems is when I deploy the application to a machine that does not have VS installed (I have downloaded and installed the "Crystal Reports Basic for Visual Studio 2008 Redistributable Package" for the appropriate processor type on this non development machine) that I'm getting an error . It prompts for "DataBase Login". The ServerName, LoginID and Password are all there, but the "DataBase" field is empty and disable for user input.</br></br>

Why is the DataBase information missing? How can I solve this problem?</br></br>

(On a side note, I vaguely remember a property for enabling/disabling the prompting of the database login. I can't remember where this was again to double check if that is the culprit. But I'm pretty sure that I did mark it as to not prompt, since it's supplied in the code behind. Plus it doesn't prompt on the development machines. Only on the non-development machines).</br></br>

Any help is greatly appreciated! Thanks.</br></br>

The code executed in the PageLoad event of the form.</br></br>

this.crystalReportViewer1.RefreshReport();</br>
            ReportDocument reportDocument = new ReportDocument();</br></br>

            #region Load Parameters</br></br>

            ParameterFields paramFields = new ParameterFields();</br></br>

            for (int i = 0; i < _parameterName.Length; i++)</br>
            {</br>
                ParameterField paramField = new ParameterField();</br>
                paramField.ParameterFieldName = _parameterName<i>;</br>
                ParameterDiscreteValue discreteVal = new ParameterDiscreteValue();</br>
                discreteVal.Value = _parameterValues<i>;</br>
                paramField.CurrentValues.Add(discreteVal);</br>
                paramFields.Add(paramField);</br>
            }</br></br>

            crystalReportViewer1.ParameterFieldInfo = paramFields;</br></br>

            #endregion</br></br>

            
            #region Load Report</br></br>

            string reportUrl = "";</br></br>
            
            string exePath = Application.ExecutablePath.ToString();</br>
            exePath = exePath.Remove(exePath.Length - 18, 18);</br>
            exePath += _reportName + ".rpt";</br>
            reportUrl = exePath;</br>
            
            reportDocument.Load(reportUrl);</br>
            
           #endregion</br></br>
           
           reportDocument.SetDatabaseLogon("myUserName", "myPassword", "myServer", "myDataBase");</br></br>


            crystalReportViewer1.ReportSource = reportDocument;

</br></br>

Edited by: mtech8 on Jan 9, 2010 3:03 PM. Corrected formatting issues to make post readable.