I’ve got the following code that I’m using to retrieve records from the database and put them in to objects.
It’s all working fine, but the Intellisense isn’t working at all.
My snippet of code, which is working fine:
<%
// Get the data context for the SMD-GROUP database
SMDGroupDBDataContext db = new SMDGroupDBDataContext();
// Query the database
IEnumerable<BestSeller> best_sellers = from bs in db.TOELINE
where bs.CusRef == "247HO001"
select new BestSeller()
{
product_code = bs.ProdCode,
product_description = bs.ProdDescr
};
// Loop through and show each line
foreach (BestSeller best_seller in best_sellers)
{
Response.Write(best_seller.product_code + " - " + best_seller.product_description + "<br/>");
}
%>
Here’s my web config file:
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<connectionStrings>
<add name="SMDPortalDbCon" connectionString="Data Source=smd-data;Initial Catalog=SMDPORTAL;User Id=**************;Password=**********;" providerName="SMDPortalMembershipProvider"/>
<add name="SMD_GROUPConnectionString" connectionString="Data Source=****;Initial Catalog=SMD-GROUP;Persist Security Info=True;User ID=******;Password=*********" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<compilation debug="true">
<assemblies>
<add assembly="UODOTNET, Version=2.2.5.7444, Culture=neutral, PublicKeyToken=335F3FBD4BE82339"/>
<add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</assemblies>
<buildProviders>
<add extension=".edmx" type="System.Data.Entity.Design.AspNet.EntityDesignerBuildProvider"/>
</buildProviders>
</compilation>
<authentication mode="Forms">
<forms loginUrl="Default.aspx" timeout="2880" cookieless="UseCookies"/>
</authentication>
<authorization>
<deny users="?"/>
</authorization>
<membership defaultProvider="SMDPortalMembershipProvider">
<providers>
<clear/>
<add name="SMDPortalMembershipProvider" type="SMDPortalMembershipProvider" connectionStringName="SMDPortalDbCon" applicationName="SmdPortal" passwordFormat="Hashed" requiresQuestionAndAnswer="false" enablePasswordRetrieval="false" enablePasswordReset="false" requiresUniqueEmail="false" minRequiredPasswordLength="3" minRequiredNonalphanumericCharacters="0"/>
</providers>
</membership>
<roleManager defaultProvider="SMDPortalRolesProvider" enabled="true">
<providers>
<clear/>
<add name="SMDPortalRolesProvider" type="SMDPortalRolesProvider" connectionStringName="SMDPortalDbCon"/>
</providers>
</roleManager>
<customErrors mode="Off"/>
<sessionState cookieName="smd_portal_session" timeout="100"/>
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</controls>
</pages>
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" validate="false" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</httpHandlers>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</httpModules>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<remove name="ScriptModule"/>
<add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></modules>
<validation validateIntegratedModeConfiguration="false"/>
<handlers>
<remove name="WebServiceHandlerFactory-Integrated"/>
<remove name="ScriptHandlerFactory"/>
<remove name="ScriptHandlerFactoryAppServices"/>
<remove name="ScriptResource"/>
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptResource" verb="GET,HEAD" path="ScriptResource.axd" preCondition="integratedMode" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</handlers>
</system.webServer>
</configuration>
Have you imported the Linq namespace at the top of your page?
Update: If you’d like to register the namespace in the web.config you would do it like this: