|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
ASP Pgm pls Rectify the problemi'm new to Dotnet subject nd i'm getting one exception while running one ASP Pgm pls rectify the problem and what actually is.... help me out here is my pgm: using System; using System.Collections; using System.ComponentModel; using System.Data; 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 System.Data.SqlClient; namespace WebApplication2 { /// <summary> /// Summary description for WebForm1. /// </summary> public class WebForm1 : System.Web.UI.Page { protected System.Web.UI.WebControls.TextBox TextBox1; protected System.Web.UI.WebControls.TextBox TextBox2; protected System.Web.UI.WebControls.Button Button1; private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here } #region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); } /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.Button1.Click += new System.EventHandler(this.Button1_Click); this.Load += new System.EventHandler(this.Page_Load); } #endregion private void Button1_Click(object sender, System.EventArgs e) { SqlConnection conn=new SqlConnection("uid=sa; pwd=;database=pubs"); SqlCommand comm; SqlDataReader dr; comm=new SqlCommand(TextBox1.Text,conn); conn.Open(); dr=comm.ExecuteReader(); while(dr.Read()) { for(int i=0; i<dr.FieldCount;i++) { TextBox2.Text +=dr[i].ToString(); } TextBox2.Text+="\n"; } dr.Close(); conn.Close(); } } } after running this one when i click the button then i'm getting this error page:........ Server Error in '/WebApplication2' Application. -------------------------------------------------------------------------------- ExecuteReader: CommandText property has not been initialized Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidOperationException: ExecuteReader: CommandText property has not been initialized Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [InvalidOperationException: ExecuteReader: CommandText property has not been initialized] System.Data.SqlClient.SqlCommand.ValidateCommand(String method, Boolean executing) System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) System.Data.SqlClient.SqlCommand.ExecuteReader() WebApplication2.WebForm1.Button1_Click(Object sender, EventArgs e) System.Web.UI.WebControls.Button.OnClick(EventArgs e) System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) System.Web.UI.Page.ProcessRequestMain() -------------------------------------------------------------------------------- Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573 |
|||||||||||||||||||||||