SqlConnectionStringBuilder resides in System.Data.SqlClient namespace. I imported the name space at the top, but the SqlConnectionStringBuilder doesn't get highlighted, the font remains in the black color. Any idea why does this happen?
RestaurantData is a public static as you see below. I called this static class in Default aspx code behind page as:
RestaurantData.SetUpSessionVariables(Session);
I get the following error:
The name 'RestaurantData' does not exist in the 开发者_JS百科current context
RestaurantData is static, i shouldn't get this error. Can you please advise...
Sounds like you don't have the namespace available to the aspx page.
check this article ... http://www.west-wind.com/WebLog/posts/753705.aspx
try adding this to right after your <%@Page ,,,,,, %> tag:
<%@ Import Namespace="Your.Name.Space" %>
if you're using 3.5 check here http://msdn.microsoft.com/en-us/library/ms164642.aspx
try using a
you can add something like this to your web.config file
<pages>
<namespaces>
<add namespace="System" />
<add namespace="System.Collections" />
<add namespace="System.Collections.Specialized" />
<add namespace="System.Configuration" />
<add namespace="System.Text" />
<add namespace="System.Text.RegularExpressions" />
<add namespace="System.Web" />
<add namespace="System.Web.Caching" />
<add namespace="System.Web.SessionState" />
<add namespace="System.Web.Security" />
<add namespace="System.Web.Profile" />
<add namespace="System.Web.UI" />
<add namespace="System.Web.UI.WebControls" />
<add namespace="System.Web.UI.WebControls.WebParts" />
<add namespace="System.Web.UI.HtmlControls" />
</namespaces>
<!-- Other elements -->
</pages>
For SqlConnectionStringBuilder, have you added a reference to System.Data.dll
?
You might need to add a using namespace directive to import the namespace for RestaurantData, e.g.
using MyWebsite.Data;
精彩评论