I am getting this error
Object reference not set to an instance of an object.
when I run a form which shows the Crystal Report after button click.
My Button Click Event code is:
Data_Conn DC = new Data_Conn(Application.StartupPath);
button1.Enabled = false;
button1.Text = "Openning..";
try
{
Application.DoEvents();
if (checkBox1.Checked)
{
DC.SelectSta("select comName,iType,iName,(qty & ' ' & unit) as qtyU,mrp,sealBscVATrs,unitPri from StockDetails sd,ItemsTbl it where it.iCode=sd.iCode;", "StockDetails");
}
else
{
button1.Text = "Report";
button1.Enabled = true;
return;
}
if (DC.getDataSet.Tables["StockDetails"].Rows.Count > 0)
{
StockDataSet SDS = new StockDataSet();
DC.getAdapter.Fill(SDS);
StockReport StR = new StockReport();
StR.SetDataSource(SDS.Tables[1]);
StR.Refresh();
showReport SR = new showReport();
SR.crystalReportViewer1.ReportSource = StR;
SR.crystalReportViewer1.Refresh();
SR.MdiParent = this.MdiParent;
SR.Show();
}
else
{
MessageBox.Show("Items not Found!!", "Winform App", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
The interesting thing is,
when I run in debugging mode(F11) then it will show the records in report(no error), but when I run without debugging mode(F5) then it will give that error...
the error show the code which in Program.cs file :
Application.Run(new Form1());
the source of this error is: CrystalDecisions.Windows.Forms
(I checked it from view details).
Please Help me..
Thanks in advanced...
Regards
Jayanta.