Note that there are some explanatory texts on larger screens.

plurals
  1. POSqlDataReader Error
    primarykey
    data
    text
    <p>I'm trying to make SqlParameter and when I run the website error appear in <code>SqlDataReader _dataReader = _command.ExecuteReader();</code></p> <p><em>Here is my code:</em></p> <pre><code>private void goLogin() { conn.ConnectionString = _connectionString; conn.Open(); string username = txt_username.Text; _sqlCodes = "SELECT ACC_PASS,ACC_ID" + "FROM ACC WHERE ACC_USER = @username"; SqlCommand _command = new SqlCommand(_sqlCodes); _command.Parameters.Add(new SqlParameter("@username",username)); SqlDataReader _dataReader = _command.ExecuteReader(); //more codes here... conn.Close(); } </code></pre> <p><em>ERROR:</em></p> <p><strong>Server Error in '/' Application.</strong></p> <p><strong>ExecuteReader:</strong> Connection property has not been initialized.</p> <p><strong>Description:</strong> 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. </p> <p><strong>Exception Details:</strong> System.InvalidOperationException: ExecuteReader: Connection property has not been initialized.</p> <p><strong>Source Error:</strong> </p> <pre><code>Line 31: SqlCommand _command = new SqlCommand(_sqlCodes); Line 32: _command.Parameters.Add(new SqlParameter("username",username)); Line 33: SqlDataReader _dataReader = _command.ExecuteReader(); Line 34: conn.Close(); Line 35: } </code></pre> <p><strong>Source File:</strong> C:\Users\arnie.mateo\Desktop\GoWireless Project Leonel\GoWireless\GoWireless\account.aspx.cs Line: 33 </p> <p><strong>Stack Trace:</strong> </p> <pre><code>[InvalidOperationException: ExecuteReader: Connection property has not been initialized.] System.Data.SqlClient.SqlCommand.ValidateCommand(String method, Boolean async) +5089605 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +87 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +32 System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) +141 System.Data.SqlClient.SqlCommand.ExecuteReader() +89 GoWireless.WebForm1.goLogin() in C:\Users\arnie.mateo\Desktop\GoWireless Project Leonel\GoWireless\GoWireless\account.aspx.cs:33 GoWireless.WebForm1.btn_login_Click(Object sender, EventArgs e) in C:\Users\arnie.mateo\Desktop\GoWireless Project Leonel\GoWireless\GoWireless\account.aspx.cs:52 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563 </code></pre> <p><strong>Version Information:</strong> Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload