2011-08-31 71 views
1

我新使用vb.net中的配置文件并试图弄清楚我做错了什么。在webconfig我有以下代码:在ASP.NET中使用配置文件

而且在我的VB代码我试图通过使用此代码添加到配置文件:

profile.FirstName = "John" 

但我不断收到错误说:

FirstName不是配置文件的成员。

有没有什么我做错了?我试图通过阅读这本书来了解这一点,但似乎在那里错过了一步。任何帮助将非常感激。

+0

你解决这个问题? – DavRob60

回答

1

确保你在你的web.config定义ProfileProvider如SqlProfileProviderTable Profile Provider

这里一个例子,你用字符串替换YOURConnectionStringYOURApplicationName

<profile defaultProvider="CustomProfileProvider" enabled="true"> 
     <providers> 
      <add name="CustomProfileProvider" 
       type="System.Web.Profile.SqlProfileProvider" 
       connectionStringName="YOURConnectionString" 
       applicationName="YOURApplicationName" 
       description="Something" /> 
     </providers> 
     <properties> 
      <add name="FirstName" type="System.String"/> 
     </properties> 
</profile> 

你也可以阅读本Article