I can't tell you how often in the past I could have used this script from David Yardy:
http://blog.davidyardy.com/archive/2008/08/16/sql-server-ndash-find-field-value-in-database.aspx
I can find a string value anywhere it exists in a field in my database. As he says, it can easily be modified to search for values that are not strings.
A place for me to store and share some notes about technical stuff I'm working with at the moment.
The views expressed on this blog are mine alone and do not necessarily reflect the views of my employer.
Wednesday, October 29, 2008
Thursday, October 09, 2008
ASP.Net Enabling the Session Object
Today I was attempting to use the Session object to exchange information between two ASP .Net pages. I received the following exception when I tried to assign something to it:
System.Web.HttpException was unhandled by user code
Message="Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive. Please also make sure that System.Web.SessionStateModule or a custom session state module is included in the\\\\ section in the application configuration."
Source="System.Web"
ErrorCode=-2147467259
StackTrace:
at System.Web.UI.Page.get_Session()
at AddToCart.SaveCustomFields() in c:\Inetpub\wwwroot\StarterSite\AddToCart.aspx.cs:line 485
at AddToCart.AddItemToCart() in c:\Inetpub\wwwroot\StarterSite\AddToCart.aspx.cs:line 490
at AddToCart.btnAddToCart_Click(Object sender, EventArgs e) in c:\Inetpub\wwwroot\StarterSite\AddToCart.aspx.cs:line 300
at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Based on information I found on the web, I first tried to set EnableSessionState="True" on every page that needed to use the session, and that didn't cure the issue.
Next, I tried setting <pages enableSessionState="true"> in the Web.config file under configuration/system.web. That didn't fix it either.
Finally, what worked was to put this into the Web.config:
<sessionState mode="InProc"></sessionState>
(also under configuration/system.web).
System.Web.HttpException was unhandled by user code
Message="Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive. Please also make sure that System.Web.SessionStateModule or a custom session state module is included in the
Source="System.Web"
ErrorCode=-2147467259
StackTrace:
at System.Web.UI.Page.get_Session()
at AddToCart.SaveCustomFields() in c:\Inetpub\wwwroot\StarterSite\AddToCart.aspx.cs:line 485
at AddToCart.AddItemToCart() in c:\Inetpub\wwwroot\StarterSite\AddToCart.aspx.cs:line 490
at AddToCart.btnAddToCart_Click(Object sender, EventArgs e) in c:\Inetpub\wwwroot\StarterSite\AddToCart.aspx.cs:line 300
at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Based on information I found on the web, I first tried to set EnableSessionState="True" on every page that needed to use the session, and that didn't cure the issue.
Next, I tried setting <pages enableSessionState="true"> in the Web.config file under configuration/system.web. That didn't fix it either.
Finally, what worked was to put this into the Web.config:
<sessionState mode="InProc"></sessionState>
(also under configuration/system.web).
Subscribe to:
Posts (Atom)