Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Weird Problem with Sessions & SQL statements!!!!

Status
Not open for further replies.

kcsants

IS-IT--Management
Apr 29, 2002
10
US
I seem to have a weird problem that may not seem so weird so someone else, I hope.

I am using a session variables to store information regarding user rights and access:
session("ACL")=true

In the same script I have a SQL statement adding a record into a Access database.

Nothing weird about that right... wrong.

When the session variable contains information the SQL statement does not work. No errors. When there is no session variables it works fine. I have reworked the script a dozen times and everything looks fine. I have even added response.write statements to follow the scripts path to insure that my variables still contain their data and that script actually gets to the point of executing, and they do.

Any ideas anyone?

Many Thanks
 
Hi ...
can you post your code here ?
----
TNX.
E.T.
 
E.T., the code is actually very long... I will post the area that pertain to this situation... here ya go:

From Accessadmin.asp script:
*Note: session variable

if rsAccess("AdminUser") = Request.Form("uname") then
if rsAccess("AdminPassword") = Request.Form("pw") then
accessPermitted = true
session("ACL") = true
end if
end if

if not session("ACL") then
Response.Redirect "adminaccess.asp"
else
Session("currentpayperiod") = Request.Form("submitperiod")
Response.Redirect "admin.asp"
end if

From submit.asp:

addPayType = paytype(1)
SQLstmt = "INSERT INTO payroll (SubmitDate,PayPeriod,PSID,BatchName,Name,Clock,PayType,HomeDepartment,Status,Comments,Hours)"
SQLstmt = SQLstmt & " VALUES ("
SQLstmt = SQLstmt & "'" & theDate & "'" & ", "
SQLstmt = SQLstmt & "'" & addPayperiod & "'" & ", "
SQLstmt = SQLstmt & "'" & addPSID & "'" & ", "
SQLstmt = SQLstmt & "'" & addBatch & "'" & ", "
SQLstmt = SQLstmt & "'" & addName & "'" & ", "
SQLstmt = SQLstmt & "'" & addClock & "'" & ", "
SQLstmt = SQLstmt & "'" & addPayType & "'" & ", "
SQLstmt = SQLstmt & "'" & addHomeDept & "'" & ", "
SQLstmt = SQLstmt & "'" & addStatus & "'" & ", "
SQLstmt = SQLstmt & "'" & addOther & "'" & ", "
SQLstmt = SQLstmt & "'" & paytype(0) & "'" & ") "
response.write (&quot;<FONT color=red>** Executed **</FONT><BR><BR>&quot;)
conn.execute(SQLstmt)

 
&quot;In the same script I have a SQL statement adding a record into a Access database&quot;

DO you have a page called &quot;adminaccess.asp&quot; and another called &quot;Accessadmin.asp&quot;?

This code will ALWAYS take someone to a new page...
if not session(&quot;ACL&quot;) then
Response.Redirect &quot;adminaccess.asp&quot;
else
Session(&quot;currentpayperiod&quot;) = Request.Form(&quot;submitperiod&quot;)
Response.Redirect &quot;admin.asp&quot;
end if


What code do you have above the execution of the SQL that is failing on page &quot;submit.asp&quot;?
-- Just trying to help...
[wolf]<--- This is a wolf? We need a new icon.......
mikewolf@tst-us.com
 
Very good questions mwolfOO.... being that there is about 20 pages and over 40 pages of script its tough for me to give you all the script but to answer your question:

the adminaccess.asp is where the session variable is set through a form entry of username and password. if the variable returns false then it just redirects back to itself for the individual to be able to re-enter.

But if the session variable is true then it forwards to the admin.asp page that allows for many different options (i.e. printing, importing, exporting, submitting, etc.)... so through selection in the admin.asp page the user will get to the submit.asp page of which the SQL statement that I am having a problem with is housed...

I hope that answers your question and doesnt confuse things further... please let me know and thanks for your interest.
 
If the error is happening on submit.asp, can you post all of that code(at least throught the execution of the script)? -- Just trying to help...
[wolf]<--- This is a wolf? We need a new icon.......
mikewolf@tst-us.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top