For some reason I am getting this error even though (as you can see from the
code in the Initialize Component procedure) the object reference has been
established... I am at my wit's end.. Thanks for any advice...
-------
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
public class x : System.Web.UI.Page
{
protected System.Data.SqlClient.SqlConnection sqlConnection1;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
sqlConnection1.Open(); <-- Error occurs on this line
}
private void InitializeComponent()
{
this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
//
// sqlConnection1
//
this.sqlConnection1.ConnectionString = "packet size=4096;user id=XXX;data
source=XXX;persist security info=False;initial catalog=XXX;password=XXX";
this.Load += new System.EventHandler(this.Page_Load);
}I think this error is occurring because you are never calling the
InitializeComponent() function, and it means the reference has not been
create when you try to open the connection.
"Mark Wilson" <mljdtj@.n.o.s.p_amhotmail.com> wrote in message
news:%23dEaF9V1DHA.2160@.TK2MSFTNGP12.phx.gbl...
> For some reason I am getting this error even though (as you can see from
the
> code in the Initialize Component procedure) the object reference has been
> established... I am at my wit's end.. Thanks for any advice...
> -------
> using System;
> using System.Collections;
> using System.ComponentModel;
> using System.Data;
> using System.Data.SqlClient;
> using System.Drawing;
> using System.Web;
> using System.Web.SessionState;
> using System.Web.UI;
> using System.Web.UI.WebControls;
> using System.Web.UI.HtmlControls;
> using CrystalDecisions.CrystalReports.Engine;
> using CrystalDecisions.Shared;
>
> public class x : System.Web.UI.Page
> {
> protected System.Data.SqlClient.SqlConnection sqlConnection1;
> private void Page_Load(object sender, System.EventArgs e)
> {
> // Put user code to initialize the page here
>
> sqlConnection1.Open(); <-- Error occurs on this line
> }
> private void InitializeComponent()
> {
> this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
> //
> // sqlConnection1
> //
> this.sqlConnection1.ConnectionString = "packet size=4096;user
id=XXX;data
> source=XXX;persist security info=False;initial catalog=XXX;password=XXX";
> this.Load += new System.EventHandler(this.Page_Load);
> }
>
Hi Joe,
I forgot to copy and paste the page Init code...here it is:
------
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
"Joe" <joe@.innerspace.net> wrote in message
news:uhqf6DW1DHA.3116@.TK2MSFTNGP11.phx.gbl...
> I think this error is occurring because you are never calling the
> InitializeComponent() function, and it means the reference has not been
> create when you try to open the connection.
>
> "Mark Wilson" <mljdtj@.n.o.s.p_amhotmail.com> wrote in message
> news:%23dEaF9V1DHA.2160@.TK2MSFTNGP12.phx.gbl...
> > For some reason I am getting this error even though (as you can see from
> the
> > code in the Initialize Component procedure) the object reference has
been
> > established... I am at my wit's end.. Thanks for any advice...
> > -------
> > using System;
> > using System.Collections;
> > using System.ComponentModel;
> > using System.Data;
> > using System.Data.SqlClient;
> > using System.Drawing;
> > using System.Web;
> > using System.Web.SessionState;
> > using System.Web.UI;
> > using System.Web.UI.WebControls;
> > using System.Web.UI.HtmlControls;
> > using CrystalDecisions.CrystalReports.Engine;
> > using CrystalDecisions.Shared;
> > public class x : System.Web.UI.Page
> > {
> > protected System.Data.SqlClient.SqlConnection sqlConnection1;
> > private void Page_Load(object sender, System.EventArgs e)
> > {
> > // Put user code to initialize the page here
> > sqlConnection1.Open(); <-- Error occurs on this line
> > }
> > private void InitializeComponent()
> > {
> > this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
> > //
> > // sqlConnection1
> > //
> > this.sqlConnection1.ConnectionString = "packet size=4096;user
> id=XXX;data
> > source=XXX;persist security info=False;initial
catalog=XXX;password=XXX";
> > this.Load += new System.EventHandler(this.Page_Load);
> > }
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment