Last post Nov 17, 2014 03:30 AM by Ashim Chatterjee
Nov 14, 2014 05:33 PM|XD40_Man|LINK
Hello! I keep getting following error: "Invalid attempt to call FieldCount when reader is closed."
The code simply deletes data from a grid. Nothing fancy ...
protected void btnClearList_Click(object sender, EventArgs e)
string host = Dns.GetHostEntry(Request.ServerVariables.Get("REMOTE_HOST")).HostName;
using(SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Ladder_PlanConnectionString"].ConnectionString))
SqlCommand cmd = new SqlCommand("SET NOCOUNT ON; DELETE FROM [dbo].[SkuSelection]", conn);
cmd.CommandType = CommandType.Text;
catch (Exception ex)
Logging log = new Logging();
Email email = new Email();
log.logError(Session["userID"].ToString(), host, Page.Title, "isUser", ex, Session.SessionID);
email.emailError(Session["userID"].ToString(), host, Page.Title, "isUser", ex, Session.SessionID);
Nov 17, 2014 03:19 AM|Michelle Ge - MSFT|LINK
According to your description and the code you provided, please refer to update the sql query as below:
SET NOCOUNT ON; Go DELETE FROM [dbo].[SkuSelection]
If there still have error message, please refer to make some break points and then debug the code steps by steps.
For more information about SET NOCOUNT, please refer to the link below:
Hope it's useful for you.
Nov 17, 2014 03:30 AM|Ashim Chatterjee|LINK
What you are binding in gvLadder ?? Can you share complete code ..the one which you shared looks fine.