gregm
Posts: 21
|
| Posted: 03/23/2007, 2:29 AM |
|
I have a login form that sets an employee ID
Session.Add("EMP_ID","41")
This goes to a calender page and I am trying to use the Session option as the parameter with the following set in the Table parameter form
Condition Type = Parameter
Field Name = EMP_ID
Condition is a "="
Parameter Name = EMP_ID
Type = Session
Use "Is Null" condition
This gives an SQL as follows
SELECT *
FROM vwVarSummary
WHERE STRT_DTE BETWEEN {DateRange}
AND EMP_ID = {EMP_ID}
When I successfully login, I get the following error
Line 1: Incorrect syntax near '='.
Any Ideas? It's driving me nuts! I would have thought that the "Is Null" would have caught this problem??
I'm using CodeCharge 3.0 / SQL Server 2000 and VB.NET with .NET 2.0
Thanks,
Greg
_________________
Greg Martin
gmartin@microresource.co.uk |
 |
 |
wkempees
|
| Posted: 03/23/2007, 1:00 PM |
|
You mention "succesful login" so the "is Null" should not be a problem.
remove the is Null and do an echo or alert of your SQL and check to make
sure your EMP_ID is actually set.
Walter
|
|
|
 |
gregm
Posts: 21
|
| Posted: 03/25/2007, 11:51 PM |
|
Thanks for the help and suggestion.
I was using a session variable in the SQL to set the EMP_ID parameter. This wasn't working so I've placed this code in the AfterInitialize code. This does work , though it's a bit of a pain to do this on every page.
dim empid as string
empid=(New TextField("",Settings.ManagementDataAccessObject.ExecuteScalar("SELECT Emp_id FROM webusers WHERE userid="&DBUtility.UserId))).GetFormattedValue("")
If IsNothing(Request.QueryString("emp_id")) Or Request.QueryString("emp_id") = "" Then
Dim params As New LinkParameterCollection()
params.Add("emp_id",empid)
Response.Redirect(Request.Url.AbsolutePath + params.ToString("GET","emp_id"))
End If
_________________
Greg Martin
gmartin@microresource.co.uk |
 |
 |
wkempees
|
| Posted: 03/26/2007, 8:17 AM |
|
From rereading you original post and the rest I conclude that you did not do
what you wrote.
As I interpreted your text:
The login procedure sets (besides the normal session vars) the EMP_ID
session var to a value corresponding to the logged in user.
Either as an add-on in the Login or on the very first or welcome page you
can do a query using the UserID, retrwiving the EMP_ID and setting the
Session(EMP_ID).
From then on your described method of using the EMP_ID type session in the
VQB Sql builder should work without any extra code.
Walter
|
|
|
 |
gregm
Posts: 21
|
| Posted: 03/26/2007, 11:51 PM |
|
Walter,
Thanks.
Originally, and what caused me the problem was.
a) Login.
b) Set the session EMP_ID variable in the Login form as long as the login is ok.
c) Load the calender form with the SQL statement using the session variable.
d) The calender is set to use the Session Variable EMP_ID as part of it's SQL statment..
The variable was definately being set, because when I temporarily used response.write(session("emp_id")) it wrote the output with the correct employee ID, but the SQL could not use the variable and crashed.
The second e-mail shows the new alternative method I'm using which does seem to work.
Thanks.
_________________
Greg Martin
gmartin@microresource.co.uk |
 |
 |
|