Friday, November 21, 2008     | Register
To start or answer a thread you will need to login...


Forum Guidelines

Please ensure you follow the bug-raising guidelines (e.g. post the full error from your Event Viewer) if you are raising a support call. To request a feature in a module, please use Feature Requests (unless you want to discuss it here in more detail first). If you have an urgent feature that you would like to see in the product then you should consider a Sponsored Enhancement.

 

First Time User? Make sure you have read the Module Config Guide in the documents folder of each module. Also check out this handy Module Deployment Guide (written by a Smart-Thinker customer!)

Configuration issues and no time to read the Forums/Documentation? See our DotNetNuke Premium Support Service.

 

We need your opinion! Please read our proposed new CrowdSourcing development method and let us know if you would be interested and if it might work.

 
 
  Forums  DotNetNuke  Simple SQL  getElement and GetProfileElement for DNN 3.x and 4.x
Previous Previous
 
Next Next
New Post 12/12/2006 2:18 PM
  Jean Thomas
2 posts
No Ranking


getElement and GetProfileElement for DNN 3.x and 4.x  (Satellite Provider)
There are several versions of the getElement and GetProfileElement functions around for the pre DNN 3.x and 4.x when the profile elements were stored in the aspnet_profile table. Now the structure is changed and the aspnet_profile table is no longer being populated. The profiles are kept in userProfile and the structure is different. Does anyone have a new version of those functions that they could post here; if not, can someone with SQL query knowledge please update them and publish them here for the rest of us novices to use. Thanks! JLT Here are those functions as they are available now: /* Add GetElement Function */ /***************************/ CREATE FUNCTION dbo.[GetElement] ( @ord AS INT, @str AS VARCHAR(8000), @delim AS VARCHAR(1) ) RETURNS INT AS BEGIN -- If input is invalid, return null. IF @str IS NULL OR LEN(@str) = 0 OR @ord IS NULL OR @ord < 1 -- @ord > [is the] expression that calculates the number of elements. OR @ord > LEN(@str) - LEN(REPLACE(@str, @delim, '')) + 1 RETURN NULL DECLARE @pos AS INT, @curord AS INT SELECT @pos = 1, @curord = 1 -- Find next element's start position and increment index. WHILE @curord < @ord SELECT @pos = CHARINDEX(@delim, @str, @pos) + 1, @curord = @curord + 1 RETURN CAST(SUBSTRING(@str, @pos, CHARINDEX(@delim, @str + @delim, @pos) - @pos) AS INT) END >>>>>>>>>> /* Add GetProfileElement Function */ /**********************************/ CREATE FUNCTION dbo.[GetProfileElement] ( @fieldName AS NVARCHAR(100), @fields AS NVARCHAR(4000), @values AS NVARCHAR(4000) ) RETURNS NVARCHAR(4000) AS BEGIN -- If input is invalid, return null. IF @fieldName IS NULL OR LEN(@fieldName) = 0 OR @fields IS NULL OR LEN(@fields) = 0 OR @values IS NULL OR LEN(@values) = 0 RETURN NULL -- locate FieldName in Fields DECLARE @fieldNameToken AS NVARCHAR(20) DECLARE @fieldNameStart AS INTEGER, @valueStart AS INTEGER, @valueLength AS INTEGER -- Only handle string type fields (:S:) SET @fieldNameStart = CHARINDEX(@fieldName + ':S',@Fields,0) -- If field is not found, return null IF @fieldNameStart = 0 RETURN NULL SET @fieldNameStart = @fieldNameStart + LEN(@fieldName) + 3 -- Get the field token which I've defined as the start of the field offset to the end of the length SET @fieldNameToken = SUBSTRING(@Fields,@fieldNameStart,LEN(@Fields)-@fieldNameStart) -- Get the values for the offset and length SET @valueStart = dbo.getelement(1,@fieldNameToken,':') SET @valueLength = dbo.getelement(2,@fieldNameToken,':') -- Check for sane values, 0 length means the profile item was stored, just no data IF @valueLength = 0 RETURN '' -- Return the string RETURN SUBSTRING(@values, @valueStart+1, @valueLength) END
 
New Post 12/22/2006 7:39 AM
  Rodney Joyce
2904 posts
www.DNNDir.com
1st Level Poster




Re: getElement and GetProfileElement for DNN 3.x and 4.x  (N/A)
Hi,

I am not sure of a function replacement, but have you seen how the core does it with the stored proc:
GetUsersByProfileProperty

eg.

SELECT U.UserId
FROM   ProfilePropertyDefinition P
INNER JOIN UserProfile UP ON P.PropertyDefinitionID = UP.PropertyDefinitionID
INNER JOIN Users U ON UP.UserID = U.UserID
WHERE (PropertyName = 'biography')

Thanks
Rodney
See our modules in action on PokerDIY, a social network for home poker players

Smart-Thinker DotNetNuke Development Blog
 
Previous Previous
 
Next Next
  Forums  DotNetNuke  Simple SQL  getElement and GetProfileElement for DNN 3.x and 4.x
Top Threads
In the past 1 week, we have 29 new thread(s) and 70 new post(s)
The most popular thread has been Re: Multipaid Sponsored Enhancements
The most active thread has been Multipaid Sponsored Enhancements / Crowdsourcing to improve modules
Smart-Thinker is powered by DotNetNuke - please support us and DotNetNuke - DotNetNuke Powered!
© 2008 Smart-Thinker   |  Privacy Statement  |  Terms Of Use