Link to home
Start Free TrialLog in
Avatar of fidman
fidman

asked on

Crystal Rerports in VB.net requesting login data to server when Dataset is the report source

I have created a crystal report which will report from a dataset. The data adapter reports a view from and SQL server DB. I have filled the dataset at the  InitializeComponent() part of my vb.net code using SqlDataAdapter1.Fill(DataSet11).  When I run my vb.net program I am prompted for parameter values for the report and then I am presented with the Database login screen requested server , DB , loging , password , etc. I should n't be getting the login screen as my report is based on a dataset which has its own sqlconnection information.  Can someone please give me some guidence on how to get past this database login screen?  
Avatar of Mike McCracken
Mike McCracken

Depending on how you built the report, Crystal still thinks it is tied to the database and is trying to open it.  It may be that it is trying to open the dataset and the dataset is requesting the login.

mlmcc
Because you have not set the login info and parameter, reports asks for it. This code here is how i set my login and param info runtime in C#

Regards
Emre

for db login piece
private void setlogoninfo(CrystalDecisions.CrystalReports.Engine.ReportDocument myreport)
            {
                  CrystalDecisions.Shared.TableLogOnInfo MyLogonInfo;
                  foreach(CrystalDecisions.CrystalReports.Engine.Table MyTable in myreport.Database.Tables)
                  {
                        
                        MyLogonInfo = MyTable.LogOnInfo;
                        if (MyTable.Name == "")
                        {
                              MyLogonInfo.ConnectionInfo.UserID = this._username;
                              MyLogonInfo.ConnectionInfo.Password = this._password;
                              MyLogonInfo.ConnectionInfo.ServerName  = this._servername;  
                              MyLogonInfo.ConnectionInfo.DatabaseName = this._databasename ;                              
                        }
                        else
                        {
                                        
                              
                              MyLogonInfo.ConnectionInfo.UserID = this._username;
                              MyLogonInfo.ConnectionInfo.Password = this._password;
                              MyLogonInfo.ConnectionInfo.ServerName  = this._servername;  
                              MyLogonInfo.ConnectionInfo.DatabaseName = this._databasename ;
                        }
                        MyTable.ApplyLogOnInfo(MyLogonInfo);                        
                        MyTable.Location = MyTable.Location.Substring(MyTable.Location.LastIndexOf(".")+1);  
                        
                  }
            }            


for parameter piece
private  CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition SetReportParameters(CrystalDecisions.CrystalReports.Engine.ReportDocument MyReport)
            {
                  //sets the parameter values for main report and sub reports if any
                  CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition ParameterFieldDefinition;
                  CrystalDecisions.Shared.ParameterDiscreteValue  ParameterDiscreteValue;
                  CrystalDecisions.Shared.ParameterValues  ParameterValues;                              
                  int paramcount;
                  paramcount = this.MyParameterValues.Count;
                  ParameterFieldDefinition = null;
                  string ConversionVariable;
                  ConversionVariable = null;                  
                  for (int i = 0; i != paramcount; i++)//have to put paramcount otherwise hard code it .works
                  {
                        ConversionVariable = Convert.ToString(MyReport.DataDefinition.ParameterFields[i].ParameterType);  
                        if (ConversionVariable == "StoreProcedureParameter")       
                        {
                              ParameterFieldDefinition = MyReport.DataDefinition.ParameterFields[i];  
                              ParameterValues = new CrystalDecisions.Shared.ParameterValues();
                              ParameterDiscreteValue = new CrystalDecisions.Shared.ParameterDiscreteValue();      
                              ParameterDiscreteValue.Value = this.MyParameterValues[i];      
                              ParameterValues.Add(ParameterDiscreteValue);
                              ParameterFieldDefinition.CurrentValues.Clear();
                              ParameterFieldDefinition.DefaultValues.Clear();  
                              ParameterFieldDefinition.ApplyCurrentValues(ParameterValues);
                        }
                  }
                  return ParameterFieldDefinition;
                                                
            }
make sure you have the crdb_adoplus.dll on the target machine (in the same location as on developmen computer)
ASKER CERTIFIED SOLUTION
Avatar of M0m0nga
M0m0nga

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Did this get resolved? I have the same problem
Have you ever set db logon with ReportDocumentClient(use Report Application Server)? I want to change server name but i can't.Can you help me?