ASP.NET2.0使ASPNETDB支持Access數據庫

一般情況下,ASP.NET2.0中ASPNETDB使用的是Sql Express數據庫,有的時候我們需要使用Access數據庫,本文介紹的是如何使ASPNETDB支持Access數據庫.

需要使用一個組件,其實是由microsoft發布的.

附件中包括了一個dll檔及一個mdb文件,dll檔需要copy到你的專案bin下,而mdb文件則需要copy到你的專案App_Data下

http://files.cnblogs.com/zzyyll2/Release.rar

 

然后就是在web.config中設置了,具體如下:

 

< configuration xmlns = " http://schemas.microsoft.com/.NetConfiguration/v2.0 " >
    
< connectionStrings >
        
< add name = " AccessFileName "  connectionString = " ~/App_Data/ASPNetDB.mdb "  providerName = " System.Data.OleDb " />
    
</ connectionStrings >
    
< system.web >         
        
< membership defaultProvider = " AccessMembershipProvider " >
            
< providers >
                
< clear />
                
< add name = " AccessMembershipProvider "  
                    type
= " Samples.AccessProviders.AccessMembershipProvider, SampleAccessProviders "  
                    connectionStringName
= " AccessFileName "  
                    enablePasswordRetrieval
= " false "  
                    enablePasswordReset
= " false "  
                    requiresUniqueEmail
= " false "  
                    requiresQuestionAndAnswer
= " false "  
                    minRequiredPasswordLength
= " 1 "  
                    minRequiredNonalphanumericCharacters
= " 0 "  
                    applicationName
= " SampleSite "  
                    hashAlgorithmType
= " SHA1 "  
                    passwordFormat
= " Hashed " />
            
</ providers >
        
</ membership >                 
        
< webParts >
            
< personalization defaultProvider = " AccessPersonalizationProvider " >
                
< providers >
                    
< add name = " AccessPersonalizationProvider "  
                        type
= " Samples.AccessProviders.AccessPersonalizationProvider, SampleAccessProviders "  
                        connectionStringName
= " AccessFileName "  
                        applicationName
= " SampleSite " />
                
</ providers >
            
</ personalization >
        
</ webParts >
         
</ system.web >
</ configuration >

 

以上代碼是必須的,你可以將以上代碼對號入座到你的web.config中.
如上配置后,你的asp.net專案就支持Access數據庫了

你可能感兴趣的:(asp.net)