YAFLogo

developerz
  • developerz
  • 65% (Friendly)
  • YAF Forumling Topic Starter
14 years ago
Has anyone been able to get the Sql Table Profile Provider to work YAF 1.9.3 ?

I'm running into a couple problems.

The first problem I'm facing is that if I have Gender defined as a profile property in the web.config I get a configuration error, because I think "Gender" is already defined in YAF profile somewhere(?).

Here's the error msg:

UserPostedImage

Now if I remove Gender profile property from my web.config, I then get another error that seems to be related to a profile confict with YAF.

Here's the error msg:

UserPostedImage

This error will go away, and my site will work if I remove: inherits="YAF.Classes.Utils.YafUserProfile" from



<profile enabled="true" defaultProvider="MyTableProfileProvider" inherits="YAF.Classes.Utils.YafUserProfile">
      <providers>
        <clear/>
        <add name="MyTableProfileProvider" connectionStringName="yafnet" applicationName="YetAnotherForumApp" type="Microsoft.Samples.SqlTableProfileProvider" table="custom_CustomProfileTable" />
        <!--
        <add name="MyStoredProcedureProfileProvider" 
                 type="Microsoft.Samples.SqlStoredProcedureProfileProvider" 
                 connectionStringName="DBConnString" 
                 setProcedure="custom_SetCustomProfileData" 
                 readProcedure="custom_GetCustomProfileData" 
                 applicationName="ShipwreckWorldApp"/>
                 -->
      </providers>
      <properties>
        <!-- config for table provider -->
        <add name="FirstName" defaultValue="[null]" customProviderData="FirstName;nvarchar"/>
        <add name="LastName" defaultValue="[null]" customProviderData="LastName;nvarchar"/>
        <!-- Can't use Gender property because it conflicts with YetAnotherForum profile properties -->
        <!-- <add name="Gender" defaultValue="[null]" customProviderData="Gender;bit"/> -->


      </properties>
    </profile>

If anyone has got the SqlTableProfileProvider to work, please let me know how you got it to work!!!

Thanks,

d.

Sponsor

developerz
  • developerz
  • 65% (Friendly)
  • YAF Forumling Topic Starter
14 years ago
I set up a new test site using the sample SQL Table Profile Provider website and YAF. Unfortunately, I'm getting the following error when clicking on the "My Profile" navigation link:

Unable to cast object of type 'ProfileCommon' to type 'YAF.Classes.Utils.YafUserProfile'.


Stack Trace: 


[InvalidCastException: Unable to cast object of type 'ProfileCommon' to type 'YAF.Classes.Utils.YafUserProfile'.]
   YAF.Classes.Utils.YafContext.GetProfile(String userName) +35
   YAF.Classes.Utils.YafCombinedUserData.InitUserData() +115
   YAF.Classes.Utils.YafCombinedUserData..ctor(MembershipUser membershipUser, Int32 userID) +63
   YAF.Classes.Utils.YafCombinedUserData..ctor(Int32 userID) +37
   YAF.Controls.ProfileYourAccount.BindData() +116
   YAF.Controls.ProfileYourAccount.Page_Load(Object sender, EventArgs e) +21
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +34
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +47
   System.Web.UI.Control.LoadRecursive() +131
   System.Web.UI.Control.LoadRecursive() +131
   System.Web.UI.Control.LoadRecursive() +131
   System.Web.UI.Control.LoadRecursive() +131
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061

 

Jaben
  • Jaben
  • 100% (Exalted)
  • YAF Developer
14 years ago
YAF profile class uses "custom data" and it's not compatible with SQL Table Profile Provider. I will make it compatible since it's pretty simple.
developerz
  • developerz
  • 65% (Friendly)
  • YAF Forumling Topic Starter
14 years ago
Jaben-

Any chance you'll be able to make it compatible before Dec. 25th? You'd seriously be the "man" if you were able to get it coded before then, but I understand if it might take a little longer.

Thanks for your help,

d.

Jaben
  • Jaben
  • 100% (Exalted)
  • YAF Developer
14 years ago
developerz wrote:

Jaben-

Any chance you'll be able to make it compatible before Dec. 25th? You'd seriously be the "man" if you were able to get it coded before then, but I understand if it might take a little longer.

Thanks for your help,

d.

I fixed issue in the latest release. It *should* work but I didn't actually test it with the SQL Table Provider.

Anyway, give is a shot and let me know.

developerz
  • developerz
  • 65% (Friendly)
  • YAF Forumling Topic Starter
14 years ago
Jaben... you da' Man! The Sql Table Profile Provider is now working!

Couple things: First, you need to add "Gender" column with Data Type 'int' and "Birthday" column with Data Type 'datetime' to the dbo.ProfileTable_1 (when using the sample database from Sql Table Profile Provider). But don't add Gender or Birthday to the Profile properties in the web.config. If you uncomment Gender or Birthday in the code below you'll get a Configuration error, stating "This profile property has already been defined."


<profile enabled="true" defaultProvider="TableProfileProvider" inherits="YAF.Classes.Utils.YafUserProfile">
			<providers>
				<clear/>
        
				<add name="TableProfileProvider" 
                         type="Microsoft.Samples.SqlTableProfileProvider" 
                         connectionStringName="yafnet" 
                         table="ProfileTable_1" 
                         applicationName="YetAnotherForumApp"/>
        <!--
                <add name="StoredProcedureProfileProvider" 
                         type="Microsoft.Samples.SqlStoredProcedureProfileProvider" 
                         connectionStringName="yafnet" 
                         setProcedure="setCustomProfileData" 
                         readProcedure="getCustomProfileData" 
                         applicationName="YetAnotherForumApp"/> -->       
			</providers>
			<properties>
                <!-- config for table provider -->
        
				<add name="FirstName" type="string" defaultValue="[null]" customProviderData="FirstName;nvarchar"/>
				<add name="LastName" type="string" defaultValue="[null]" customProviderData="LastName;nvarchar"/>
        <add name="Age" type="int" customProviderData="Age;int"/>
        <!-- <add name="Gender" type="int" customProviderData="Gender;int"/> -->
        <!-- <add name="Birthday" type="DateTime" customProviderData="Birthday;DateTime"/> -->
                <!-- config for stored procedure provider -->
                <!--
				        <add name="FirstName" defaultValue="[null]" customProviderData="FirstName;nvarchar;50"/>
				        <add name="LastName"  defaultValue="[null]" customProviderData="LastName;nvarchar;50"/>
                <add name="Age" type="int" customProviderData="Age;int;1"/>
                -->
			</properties>
		</profile>

It seems strange that you have to add only "Gender" and "Birthday" to the dbo.ProfileTable_1

Just looking at the UserProfile.cs file, it appears that only Gender and Birthday are the only properties that are NOT a NVARCHAR data type, ex:

Location;nvarchar;255

Homepage;nvarchar;255

MSN;nvarchar;255

YIM;nvarchar;255

AIM;nvarchar;255

ICQ;nvarchar;255

GoogleTalk;nvarchar;255

Skype;nvarchar;255

Blog;nvarchar;255

BlogServiceUrl;nvarchar;255

BlogServiceUsername;nvarchar;255

BlogServicePassword;nvarchar;255

RealName;nvarchar;255

Occupation;nvarchar;400

Interests;nvarchar;400

Gender;int

Birthday;DateTime


Anyway, thanks so much for getting things to work!!!

daCodez
  • daCodez
  • 51.2% (Neutral)
  • YAF Forumling
12 years ago
I keep getting this error when using SqlStoredProcedureProfileProvider does anyone know why?

Could not load type 'SqlStoredProcedureProfileProvider'. (C:\www\YAF\YAF-v1.9.4-RC1-SRC\YetAnotherForum.NET\web.config line 114). Please help as this is URGENT.

I've gone through all the documentation on integrating with my existing membership and have also implemented the fix here and i can't seem to get it to work.

This is my Profile Code.