polynominal
asked on
C# app not running correctly
I have added a developed an app in c# with a Crystal report, but Im having problems with it, due to the fact that the database I am logging onto has a username and password. The code is below after the question. I am getting the error messages
The name reportdocument1 does not exist in the class or namespace
Can anybody help
Thanks
Poly
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
using System.IO;
namespace WindowsApplication1
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private WindowsApplication1.Applic ation_Form
application_Form;
private CrystalDecisions.Windows.F orms.Cryst alReportVi ewer crystalReportViewer1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Cont ainer components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceM anager resources = new System.Resources.ResourceM anager(typ eof(Form1) );
TableLogOnInfos crTableLogonInfos = new TableLogOnInfos();
reportDocument1 = new OpenRecords();
ConnectionInfo crConnectionInfo = new ConnectionInfo();
crConnectionInfo.ServerNam e =
System.Configuration.Confi gurationSe ttings.App Sett ings["Server"];
crConnectionInfo.DatabaseN ame =
System.Configuration.Confi gurationSe ttings.App Sett ings["DataBase"] ;
crConnectionInfo.UserID =
System.Configuration.Confi gurationSe ttings.App Sett ings["User"] ;
crConnectionInfo.Password =
System.Configuration.Confi gurationSe ttings.App Sett ings["Password"] ;
foreach (CrystalDecisions.CrystalR eports.Eng ine.Table table in
reportDocument1.Database.T ables)
{
TableLogOnInfo crTableLogonInfo = new TableLogOnInfo();
crTableLogonInfo.TableName = table.Name;
crTableLogonInfo.Connectio nInfo = crConnectionInfo;
crTableLogonInfos.Add( crTableLogonInfo);
table.ApplyLogOnInfo( crTableLogonInfo);
}
CrystalReportViewer1.LogOn Info = crTableLogonInfos;
this.application_Form = new WindowsApplication1.Applic ation_Form ();
this.crystalReportViewer1 = new CrystalDecisions.Windows.F orms.Cryst alReportVi ewer();
this.SuspendLayout();
//
// application_Form
//
this.application_Form.File Name = "";
//
// crystalReportViewer1
//
this.crystalReportViewer1. ActiveView Index = -1; this.crystalReportViewer1. Dock = System.Windows.Forms.DockS tyle.Fill;
this.crystalReportViewer1. Location = new System.Drawing.Point(0, 0);
this.crystalReportViewer1. Name = "crystalReportViewer1";
this.crystalReportViewer1. ReportSour ce = this.application_Form;
this.crystalReportViewer1. Size = new System.Drawing.Size(292, 266);
this.crystalReportViewer1. TabIndex = 0;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.cry stalReport Viewer1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
}
}
The name reportdocument1 does not exist in the class or namespace
Can anybody help
Thanks
Poly
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
using System.IO;
namespace WindowsApplication1
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private WindowsApplication1.Applic
application_Form;
private CrystalDecisions.Windows.F
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Cont
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceM
TableLogOnInfos crTableLogonInfos = new TableLogOnInfos();
reportDocument1 = new OpenRecords();
ConnectionInfo crConnectionInfo = new ConnectionInfo();
crConnectionInfo.ServerNam
System.Configuration.Confi
crConnectionInfo.DatabaseN
System.Configuration.Confi
crConnectionInfo.UserID =
System.Configuration.Confi
crConnectionInfo.Password =
System.Configuration.Confi
foreach (CrystalDecisions.CrystalR
reportDocument1.Database.T
{
TableLogOnInfo crTableLogonInfo = new TableLogOnInfo();
crTableLogonInfo.TableName
crTableLogonInfo.Connectio
crTableLogonInfos.Add( crTableLogonInfo);
table.ApplyLogOnInfo( crTableLogonInfo);
}
CrystalReportViewer1.LogOn
this.application_Form = new WindowsApplication1.Applic
this.crystalReportViewer1 = new CrystalDecisions.Windows.F
this.SuspendLayout();
//
// application_Form
//
this.application_Form.File
//
// crystalReportViewer1
//
this.crystalReportViewer1.
this.crystalReportViewer1.
this.crystalReportViewer1.
this.crystalReportViewer1.
this.crystalReportViewer1.
this.crystalReportViewer1.
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.cry
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You did not initialize reportDocument1. I'm no crystal reports specialist, but I guess you could try
object reportDocument1 = new OpenRecords();