Overblog
Editer l'article Suivre ce blog Administration + Créer mon blog

Présentation

  • : Romagny13 - Du .NET,du pur .NET
  • : Cycle de progression Faire (quelque chose qui marche) -> comprendre ce que l’on fait/comment cela marche -> pousser plus loin les notions
  • Contact

Recherche

Articles RÉCents

8 août 2007 3 08 /08 /août /2007 17:59
[ASP.NET 2.0] –
ObjectDataSource et Caching
 
après avoir activé la notification des tables grâce à l’utilitaire aspnet_regsql.exe
objectDataSource + Web.config
<form id="form1" runat="server">
    <div>
        <br />
        <asp:ObjectDataSource
                    ID="ObjectDataSource1"
                    runat="server"
                    OnSelecting="ObjectDataSource1_Selecting"
                    SelectMethod="GetContacts"
                    TypeName="ContactCaching.BLL.ContactCtrl"
                    EnableCaching="True"
                    SqlCacheDependency="ContactDB:Contact">
            </asp:ObjectDataSource>
 
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label></div>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="ObjectDataSource1">
            <Columns>
                <asp:BoundField DataField="ContactID" HeaderText="ContactID" SortExpression="ContactID" />
                <asp:BoundField DataField="Contactname" HeaderText="Contactname" SortExpression="Contactname" />
                <asp:BoundField DataField="ContactAge" HeaderText="ContactAge" SortExpression="ContactAge" />
                <asp:BoundField DataField="ContactCategoryID" HeaderText="ContactCategoryID" SortExpression="ContactCategoryID" />
            </Columns>
        </asp:GridView>
    </form>
 
-          EnableCaching : caching pris en charge sur True
-          SqlCacheDependency = « nombase :nomtable »
Si plusieurs tables séparer chaque couple db/table par un point virgule
 ex : SqlCacheDependency= “ContactDB :Contact ;ContactDB :ContactCategory »
Web.config
<?xml version="1.0"?>
<configuration>
      <appSettings/>
      <connectionStrings>
            <add name="connectionString1" connectionString="Data Source=.;Initial Catalog=ContactDB;Integrated Security=SSPI;" providerName="System.Data.SqlClient"/>
      </connectionStrings>
      <system.web>
            <caching>
                <sqlCacheDependency enabled="true" pollTime="1000">
                     <databases>
                          <add name="ContactDB" connectionStringName="connectionString1"/>
                     </databases>
                </sqlCacheDependency>
          </caching>
            <compilation debug="true"/>
            <authentication mode="Windows"/>
      </system.web>
</configuration>
 
Partager cet article
Repost0

commentaires