Register  Login  
  February 9, 2012  
Forum    
Forum Minimize
 
ForumForumDiscussionsDiscussionsSQLGridSelected...SQLGridSelected...Finding who is logged onFinding who is logged on
Previous Previous
 
Next Next
New Post
 3/11/2010 11:45 AM
 

I have a sql db, where i register info connected to a user. In this table there is a field called 'user'. I can see information from all users in SGSV, but would like to only see the information on the user that is presentluy logged in.
I have tried different SQL sentences with WHERE in the SELECT statement, but cannot get 'hold' of the user presently logged in. Is it a db field or how do I get a filter that only show information about the logged in user ??

Mike

New Post
 3/11/2010 1:25 PM
 

Mike,

SGSV has many substitution parameters that will resolve to the correct value at run time. One of them is the current users. Use [DNN:Userid] in the Select statement and will resolve to the appropriate userid. Check out the documentaton for the other substitution parameters ... over 100.

You may also want to check out the several SQL Tip and Tricks I have presented -- most recently at Orlando DotNetNuke User Group -- see http://www.tressleworks.ca/FreeModule...

Hope this helps
Paul.

New Post
 3/12/2010 5:14 AM
 

Thanks Paul

It worked with [DNN:Userid] and I got the number as a return value - I tried to change it to [DNN:USERINFO:Username]
as to get the name (which is what I have in my table) - but this didn't work - I keep getting:
Execute SQL:Invalid column name 'hostmike'
hostmke is the login name to DNN Host
Another basic question I have is can I do scripts in SGSV or is it only SQL statements -

My questions most probably shows I am a 'novice' and hope it is not a bother to you

Mike

New Post
 3/12/2010 12:55 PM
 

Mike,

Can you post the select that caused the error .. may be a simple error. Did you use single quotes or double quotes. Double quotes will can be considered a reference to a column.

Paul.

New Post
 3/12/2010 2:19 PM
 

Hi Paul,

Thanks for a speedy answer. Below the full Sql sentence. As you see I have a db called carakostplan and a few calculations fields, and an inner join. In the carakostplan 'bruger' is a key field identifying the user and I only want the user to see his/her own info

SELECT
carakostplan.bruger,carakostplan.bruger,carakostplan.Dato, carakostplan.Vejning,carakostplan.Maaltid,carakostplan.Madvare,
caramadvare.kcal/100*Vejning AS Forbrugt,
caramadvare.fedtindhold/100*Vejning AS Fedt,
caramadvare.proteinindhold/100*Vejning AS Protein,
caramadvare.sukkerindhold/100*Vejning AS Kulhyrat

FROM (carakostplan INNER JOIN caramadvare ON carakostplan.madvare = caramadvare.Madvare)

WHERE carakostplan.bruger = [DNN:Username]

ORDER by carakostplan.Maaltid ;

Thanks

Mike

New Post
 3/12/2010 10:39 PM
 

Mike,

Looks like you need to place single quotes on the where clause as follow

WHERE carakostplan.bruger = '[DNN:Username]'

Also you may want to enable Display SQL option so you can see the resulting SQL command sent to the database.
You should be able to copy the SQL into the MS SSMS and see it works.

Hope this helps,
Paul.

New Post
 3/13/2010 3:31 AM
 

Hi again

Thanks Paul - simple and how obvious- once you see it

Mike

New Post
 3/13/2010 10:42 PM
 

Mike -- not to worry. I have done this many times ...

It's one of the reasons behind "pair-programming" -- but this often difficult if you are working alone - as I do when working on DotNetNuke.

Paul.

Previous Previous
 
Next Next
ForumForumDiscussionsDiscussionsSQLGridSelected...SQLGridSelected...Finding who is logged onFinding who is logged on

Print  

  Home | Blog | Forum | Subscriptions | Free Modules | Videos   Page generated in 0.140976 seconds.
  Copyright 2010 by TressleWorks   Terms Of Use | Privacy Statement