ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old April 5th, 2003, 06:48 AM
dragonsteve dragonsteve is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: Belgium, Poperinge
Posts: 12 dragonsteve User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Asp session variable problem

Hi,

I have a problem with my session variables.
I'll try to explain:

I am creating a site in flash in combination with asp.
I have several databases I use in my site.
When the user clicks on a button in my flash movie I open an asp page in my body frame.
I pass the variables necessary for my asp page to that asp page.
These are : my database file and table.
These two variables I place in a session variable.
PHP Code:
 session("database") = request.querystring("database")
   
session("tablename") = request.querystring("tablename"


I also open an other page in my top frame representing the alfabeth. (Also in flash)
When the user click's on a letter I call the same asp page with variable "filter" passed to it. I do not pass the database and table variables.
Instead I use the session("database") and session("tablename") for my query together with my filter to load the necessary data.

No the problem I'm having is:
I have two items in my menu,
- Labels menuitem , database="Labels.mdb"
- Artists menuitem , database="Artists.mdb"

I click on labels, my selected database is Labels.mdb.
When clicking on my letter of the alfabeth it filters correctly.
I switch to Artists, now my selected database is Artists.mdb.
When clicking on my letters of the alfabeth it filters correctly when there is data found. When no data is found it switches for some strange reason to the Labels.mdb database where for the selected lettre there is data.

I can't understand why it is doing that.
Could somebody help me with this problem.

THX

Reply With Quote
  #2  
Old April 5th, 2003, 02:03 PM
rdoekes rdoekes is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Strasbourg, France
Posts: 181 rdoekes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 20 sec
Reputation Power: 16
Send a message via AIM to rdoekes Send a message via Yahoo to rdoekes
maybe this is not want you are looking for, but wouldn't it be a lot easier when you ISO two databases merge both databases in one database.

In that case you do not need to use a session variable to hold the database name, but you can be assured that you always connect to the right database.

Then you only need to worry about defining a database connection string once (or use 1 DSN).

Hope this helps,

-Rogier
__________________
- Rogier Doekes

Reply With Quote
  #3  
Old April 5th, 2003, 08:28 PM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Posts: 2,056 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 44 m 22 sec
Reputation Power: 0
Show us the code which uses the session var's to select the DB

Reply With Quote
  #4  
Old April 6th, 2003, 04:06 AM
dragonsteve dragonsteve is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: Belgium, Poperinge
Posts: 12 dragonsteve User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
This my ASP code of my page:

PHP Code:
<%@Language="VBScript"%>
<%
    if 
Session("filter") = "" then
        Session
("filter")="A"
        
Session("nbr")=1
        Session
("Count")=0
    end 
if
    
dim sConn
    Dim oConn
    Set oConn 
Server.CreateObject("ADODB.Connection")
    
    if 
request.querystring("database") <> "" then
        session
("database") = request.querystring("database")
        
session("tablename") = request.querystring("table")
    
end if
    
Session("filter") = request.querystring("filter")
  
    
sConn "provider=Microsoft.jet.oledb.4.0; data source = " Server.MapPath("/")  & "\" & session("database")

    function loadLinks(sDatabase, sTableName)
        Dim oRS
         Dim collects
        dim returnString
        
        ' *** For test purpose
        'returnString = "
SELECT FROM " & sTableName & " WHERE filter '" & Session("filter") & "' AND seqnbr >= " & Session("nbr") & " AND seqnbr <= " & Session("nbr") + 10 & " ORDER BY Name"
        'returnString = returnString & "        
provider=Microsoft.jet.oledb.4.0data source " & Server.MapPath("/")  & "\" & Session("database")
        
        returnString = "
<div name=""moveBack"" style=""background-colortransparentborderBlackwidth164height32background-imageurl(file:///C|/Inetpub/wwwroot/drweirdo/Update/images/linkbutton.gif);color:white;  text-align: center; vertical-align: baseline; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-style: normal; font-size: xx-small; padding-top: 8;"" onClick=""moveBack();"">Back</div>"
         
Set oRS Server.CreateObject("ADODB.Recordset")
        
         if 
oConn.State adStateClosed then
             oConn
.Open sConn
         end 
if
        
oRS.Open "SELECT * FROM " sTableName " WHERE filter = '" Session("filter") & "' AND seqnbr >= " Session("nbr") & " AND seqnbr <= " Session("nbr") + 10 " ORDER BY Name" oConn23
        
         
If not oRS.EOF Then
            Session
("Count") = oRS("filterCount")
             Do While 
Not oRS.EOF
                returnString 
returnString "<div name=" oRS("id") & " style='background-color: transparent; border: Black; width: 164; height: 32; background-image: url(file:///C|/Inetpub/wwwroot/drweirdo/Update/images/linkbutton.gif);color:white; text-align: center; vertical-align: baseline; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-style: normal; font-size: xx-small; padding-top: 8;' onClick=openLink(this.childNodes) onMouseOver=setComment(this.childNodes) onMouseOut=unsetComment()>"
                ' *** Index = 0
                returnString = returnString & "<input type=hidden name=""" & oRS("id") & "comment"" value=""" & oRS("Comment") & """>"
                ' 
*** Index 1
                returnString 
returnString "<input type=hidden name=""" oRS("id") & "link"" value=""" oRS("Url") & """>"
                ' *** Index = 2
                returnString = returnString & "<input type=hidden name=""" & oRS("id") & "title"" value=""" & oRS("Title") & vbcrlf & """>"
                ' 
*** Index 3
                returnString 
returnString "<input type=hidden name=""" oRS("id") & "label"" value=""" oRS("Label") & vbcrlf """>"
                
returnString returnString oRS("Name")
                
returnString returnString "</DIV>"
                
oRS.MoveNext
           Loop
         End 
If
        
oRS.Close
        Set oRS 
Nothing
        oConn
.Close
        Set oConn 
Nothing
        returnString 
returnString "<div name=""moveForward"" style=""background-color: transparent; border: Black; width: 164; height: 32; background-image: url(file:///C|/Inetpub/wwwroot/drweirdo/Update/images/linkbutton.gif);color:white;  text-align: center; vertical-align: baseline; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-style: normal; font-size: xx-small; padding-top: 8;"" onClick=""moveForward();"">Next</div>"
        
loadLinks returnString
    end 
function 

Reply With Quote
  #5  
Old April 6th, 2003, 06:34 AM
rdoekes rdoekes is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Strasbourg, France
Posts: 181 rdoekes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 20 sec
Reputation Power: 16
Send a message via AIM to rdoekes Send a message via Yahoo to rdoekes
You use session variables to move the data from one frame to the other.

However, the scope of session variables is the time the user is in your application and no time out occurred.

So if the user selects labels first than the session var Session("database") contains the labels.mdb.

You do a test
If Request.Querystring("database") <> "" Then

However you describe a case when the querystring for database is empty. Therefore it does not update the Session("database") but takes whatever value is in there.

Reply With Quote
  #6  
Old April 6th, 2003, 06:55 AM
dragonsteve dragonsteve is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: Belgium, Poperinge
Posts: 12 dragonsteve User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Yes that's wright,

the user has two options.
Either he clicks a menu item and the database for the clicked item is selected and passed to the asp page. There I put it in the session variable database.
On the other hand the user uses the abc list to select a filter on the selected database. Here I don't pass the database to it, simply because my top frame doesn't know the database. Therefore I use the session variable database to know my current database I'm using.

Reply With Quote
  #7  
Old April 12th, 2003, 10:16 AM
dragonsteve dragonsteve is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: Belgium, Poperinge
Posts: 12 dragonsteve User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Urgent help required

Hi again,

I seem not to be getting any replies anymore.
I have created some logging on my site for trying to filter out the problem.
So now I have found that when...:

1. I select from my menu "Labels"
1a. This results in showing of the page with a filter A and database Labels.
2. I select a new lettre -- let's say F
2a. This results in showing the page with filter equal to F
3. I select a new menu item "Artists"
3a. This results in showing the page with the filter equal to A
4. I select the lettre F from my alfabeth.
4a. This results in showing the page with filter F but not from the database of the Artists but that of Labels.

This happens only on the lettre's I've selected in the previous page.

I'm looking for a solution but I can't find one.
Could somebody help me please.
On request I am willing to provide code and databases.

THX

Reply With Quote
  #8  
Old April 12th, 2003, 04:26 PM
rdoekes rdoekes is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Strasbourg, France
Posts: 181 rdoekes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 20 sec
Reputation Power: 16
Send a message via AIM to rdoekes Send a message via Yahoo to rdoekes
hi dragonsteve,

Please send me code and databases; i will see what i can do to help.

Reply With Quote
  #9  
Old April 19th, 2003, 05:28 AM
dragonsteve dragonsteve is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: Belgium, Poperinge
Posts: 12 dragonsteve User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
hi rdoekes,

did you find the code and databases?

Reply With Quote
  #10  
Old April 20th, 2003, 05:29 PM
rdoekes rdoekes is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Strasbourg, France
Posts: 181 rdoekes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 20 sec
Reputation Power: 16
Send a message via AIM to rdoekes Send a message via Yahoo to rdoekes
I give up. Cannot think of something illuminating.

I can only think of these things:

1.
PHP Code:
if Session("filter") = "" then
  Session
("filter")="A"
  
Session("nbr")=1
  Session
("Count")=0
end 
if
......
Session("filter") = request.querystring("filter"


First you define session("filter") if it doesn't exists, then you turn around and overwrite that value with a querysting parameter.

2. in your topabc.swf every letter is coded
PHP Code:
 loadpage.asp?filter=x&sF=
except for the letter A:
PHP Code:
 loadpage.asp?database=&filter=A&sF=

any reason why the querysting is different for the letter A?


But I do not think that these things will explain your problems.

btw: any reason why you are using multiple databases ISO one database with 2 tables? Makes it easier, since you only need 1 connectionstring to one database, and you can eliminate the need for a session variable carrying the datasename.


Anyone else who wants to take a crack at this?

Thanks,

Last edited by rdoekes : April 20th, 2003 at 05:32 PM.

Reply With Quote
  #11  
Old April 21st, 2003, 10:10 AM
dragonsteve dragonsteve is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: Belgium, Poperinge
Posts: 12 dragonsteve User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thx rdoekes,

I already have narrowed the problem down to the caching of my files.
When clicking on a link the file and his querystrings are stored in the temperary internet files. So when you do a call with the same querystring this results in the same page.

So now I need a solution that, when a user clicks on a link this always refreshes the page. In other words, that the system does not take the file from the temperary internet files.

PS: I placed all the tables in one database.

Reply With Quote
  #12  
Old April 21st, 2003, 10:23 AM
dragonsteve dragonsteve is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: Belgium, Poperinge
Posts: 12 dragonsteve User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Problem solved,

I had to place the following code in my page.

PHP Code:
 Response.Expires 60
Response
.Expiresabsolute Now() - 1
Response
.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","private"
Response.CacheControl "no-cache" 


Thx for the help

Reply With Quote
  #13  
Old April 21st, 2003, 10:41 AM
rdoekes rdoekes is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Strasbourg, France
Posts: 181 rdoekes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 20 sec
Reputation Power: 16
Send a message via AIM to rdoekes Send a message via Yahoo to rdoekes
When it has to do with caching than you're last post indeed is the solution.

btw: nice web app you have there

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > Asp session variable problem


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap