Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsReportsReportsPassing logged on userid or username to sql queryPassing logged on userid or username to sql query
Previous
 
Next
New Post
4/27/2009 11:09 AM
 

I am not a programmer and haven't really done any programming in ten years. I do know some basic stuff which is enough to be dangerous.... Anyways I have this client with a DNN portal site setup for their HR department. They have an access database that they would like some information displayed to the user on the DNN site. I have done simple db to web things before so I got into it. The reports module seemed to fit the bill right away and it does work. It displays the relevant data I need it to. Only problem is that I need to be able to pass the logged in USERID or USERNAME from DNN to the sql query back to access. If I statically put in the variable it works fine. I have searched and searched and think I finally came up with &USERID for the variable from DNN. But when I input this into the query it runs fine but never comes back with any data which tells me I am either using the wrong variable, I have the wrong syntax in the query, or It just plain will not work or function in the way I want it to. I keep reading places where people say it cannot be done but I am not sure if that pertains to what I am trying to do?? If it can't be done with the reports module then what can I do it with as this seems like a very simple operation and should not require me to have all these headaches just to pass one variable. 

FROM [HR Employee Records]
WHERE ((([HR Employee Records].[ID1])=[@USERID]));

 

Please and thank you for any advice.

Berenger

 
New Post
4/27/2009 2:41 PM
 

The Reports module does pass the UserId to the data source, but the exact format of the parameter may depend on the database you are using.  My quick research shows that you have the right format for the parameter (though I would double check the casing, the parameter is passed as "UserId".  I don't think parameters are case-sensitive, but it doesn't hurt to check ).

I assume you are using the "Generic ADO.Net Data Source", have you set the "Parameter Name Prefix" to "@"?  Since ADO.Net doesn't tell us what format the parameter names are expected in, you have to specify it.  The default is "@", which I believe should work for Access, but again, it doesn't hurt to double-check.

This should absolutely be a supported scenario, so I hope we can sort this problem out for you.

-Andrew


Andrew Nurse
DotNetNuke Core Team Member and Reports Module Project Lead
Microsoft Certified Professional Developer

 
New Post
5/4/2009 5:17 PM
 

I have been busy with other things and just got back to this. Everything you said is correct as I am using those settings. I tried the case and it made no difference.  Is there a way I can display the sql query that gets sent to access? So I can see the parameter in place instead of my @UserId ... I don't have much reference on these parameters so I am assuming UserId would equate to an integer and not a string like ID:7 that I see in the user settings cp. It is so simple I do not understand why it is not working. I have userid 7 and in the database is userid 7. When I put in "@UserId" it displays nothing but when I put a 7 there it shows my data.

ADO.Net Data Provider: OleDb

Connection String: Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\db\HR Employee Records - 2009.mdb

parameter prefix: @

FROM [HR Employee Records]
WHERE ((([HR Employee Records].[ID1])=["UserId"]));

 

 
New Post
5/5/2009 2:37 AM
 

I should clarify my earlier comment about the parameter name.  From my research, the Jet database engine (which powers Access) requires that parameters start with an "@" symbol.  So when I said the parameter was called "UserId", I meant: @UserId . Your query shows "UserId", but the rest of your post says @UserId, so I just want to make sure we're 100% clear on that.

I'm still not fully convinced that's the problem though... Unfortunately I don't know of a way to examine the query sent to Access (SQL Server has a "Profiler" which lets you do this, but I'm not familiar with a similar tool for Access).  I can tell you that the parameter is passed as an integer (i.e. 7), not a string.

All I could suggest is trying to use the parameter in an Access query directly (not being deeply familiar with Access, I can't say for sure how to do that).

If you are able to (I realize there may be data confidentiality issues that prevent this) could you either post the full query here, or sent it to me via email if you'd prefer a more confidential route.  Your posts have only contained a fragment of the query, and more information might help debug this issue.

Thanks!

-Andrew


Andrew Nurse
DotNetNuke Core Team Member and Reports Module Project Lead
Microsoft Certified Professional Developer

 
New Post
6/2/2009 11:32 AM
 

Hi,

do not know if you have resolved this, or even if this helps but @UserID returns a number.  so to get the actual username it would be

SELECT

UserName

FROM

Users

WHERE

UserID = @UserID

this is ofcourse if your HR database is looking for the actual name, not the DNN ID number.

Anyho

 

cheers

 

 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsReportsReportsPassing logged on userid or username to sql queryPassing logged on userid or username to sql query


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out