 |
 |
|

11-06-2002, 10:34 AM
|
|
Centurion
|
|
Join Date: Apr 2002
Location: Newfoundland
Posts: 123
|
|
Problem with writing Twice
|
Has anyone ever had a problem with asp writing twice to a database for no apparent reason because my code is in the global.asa and shouldn't the global just fire once when the user enter the site?
SQL = "insert into tblvisitor(UNnumber, DateTimeEntrance, IPAddress, UserAgent, "
SQL = SQL & "Browser, DHTML, Frames, Tables, Cookies, "
SQL = SQL & "BackgroundSounds, JavaScript, JavaApplets, "
SQL = SQL & "ActiveXControls, AOL, Platform, VBScript) values("
SQL = SQL & "'" & Session("RandomNum") & "', "
SQL = SQL & "'" & DateTimeEntrance & "', "
SQL = SQL & "'" & Session("IPAddress") & "', "
SQL = SQL & "'" & UserAgent & "', "
SQL = SQL & "'" & Browseris & "', "
SQL = SQL & "'" & DHTMLSupport & "', "
SQL = SQL & "'" & FramesSupport & "', "
SQL = SQL & "'" & TablesSupport & "', "
SQL = SQL & "'" & CookiesSupport & "', "
SQL = SQL & "'" & BackgroundSounds & "', "
SQL = SQL & "'" & JavaScriptSupport & "', "
SQL = SQL & "'" & JavaAppletsSupport & "', "
SQL = SQL & "'" & ActiveXControlsSupport & "', "
SQL = SQL & "'" & AOL & "', "
SQL = SQL & "'" & Platformis & "', "
SQL = SQL & "'" & VBScriptSupport & "') "
'Execute the above query
conn.execute SQL
set rstRecordID = conn.execute("select RecordID from tblvisitor " _
& " where IPAddress = " & "'" & Session("IPAddress") & "' and UNnumber = " & Session("RandomNum"))
Session("RecordID") = clng(rstRecordID("RecordID"))
conn.close
set conn = Nothing
|
__________________
- - Renidragd - -
|

11-06-2002, 12:49 PM
|
 |
Contributor
|
|
Join Date: Oct 2002
Location: Virginia, USA
Posts: 716
|
|
|
Hello,
I am going to assume that you have placed this code in the Session_OnStart subroutine.
Are there any similarities in the repeated entries, such as CookiesSupport being false or off or whatever you use to denote that they are not supported?
In order to use session variables, I believe that the user must have cookies enabled. The SessionID is stored locally via a cookie. Otherwise, the browser will get a new SessionID (and therefore retrigger the Session_OnStart event) every time they go to a new page...
Hope this helps!
|
__________________
I honestly think you ought to calm down; take a stress pill and think things over. - HAL 9000 (2001: A Space Odyssey)
|

11-06-2002, 06:37 PM
|
|
Centurion
|
|
Join Date: Apr 2002
Location: Newfoundland
Posts: 123
|
|
|
I started this site about 2 weeks ago and I am just getting this problem starting today and I haven't changed anything in the global.asa file since i created it, and like I said it has worked fine up until today.
and each write to the data base happens at the exact time or 1 sec apart so their isn't anything on the following pages that trigger this to write again
|
__________________
- - Renidragd - -
|

11-07-2002, 06:37 AM
|
 |
Contributor
|
|
Join Date: Oct 2002
Location: Virginia, USA
Posts: 716
|
|
|
could you post a couple of related records that exhibit this (hiding the IPs of course...don't need those...just mask them or something...)...that may help in tracking this issue down...
|
__________________
I honestly think you ought to calm down; take a stress pill and think things over. - HAL 9000 (2001: A Space Odyssey)
|

11-07-2002, 11:35 AM
|
|
Centurion
|
|
Join Date: Apr 2002
Location: Newfoundland
Posts: 123
|
|
|
This problem is only happening when the asp application first fires and the script is in the global.asa.
Here are a few of the feilds from some records but I can't see any conflicts with the cookies being enabled, it is happening twice for them also :
Headings are: UserAgent, Browser, DHTML, Frames, Tables, Cookies, BackgroundSounds, JavaScript.
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0) Netscape 4.00 unknown True True True False True
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0) Netscape 4.00 unknown True True True False True
Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0 Default 0.0 unknown False True False False False
Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0 Default 0.0 unknown False True False False False
Mozilla/4.61 [en]C-CCK-MCD (Win95; U) Default 0.0 unknown False True False False False
Mozilla/4.61 [en]C-CCK-MCD (Win95; U) Default 0.0 unknown False True False False False
Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt; Hotbar 3.0) IE 5.0 unknown True True True True True
Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt; Hotbar 3.0) IE 5.0 unknown True True True True True
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0) Netscape 4.00 unknown True True True False True
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0) Netscape 4.00 unknown True True True False True
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0) Netscape 4.00 unknown True True True False True
Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Q312461) Netscape 4.00 unknown True True True False True
Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Q312461) Netscape 4.00 unknown True True True False True
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0) Netscape 4.00 unknown True True True False True
|
__________________
- - Renidragd - -
|

11-07-2002, 11:53 AM
|
 |
Contributor
|
|
Join Date: Oct 2002
Location: Virginia, USA
Posts: 716
|
|
You've got me stumped 
...I'll let you know if I come across anything for this though - anyone else got any ideas about this one?
|
__________________
I honestly think you ought to calm down; take a stress pill and think things over. - HAL 9000 (2001: A Space Odyssey)
|

11-07-2002, 12:02 PM
|
|
Centurion
|
|
Join Date: Apr 2002
Location: Newfoundland
Posts: 123
|
|
|
I really appreciate you trying to help. I am not finding much out there for help with ASP.
I am glued to this site for all my VB needs but with this project I am into now being mostly web and asp I am really trying to find a forum dedicated to ASP, do you know of any that are as resourceful as this one is for VB?
Thanks again for looking this over.
|
__________________
- - Renidragd - -
|

11-07-2002, 12:53 PM
|
|
|
|
Could you take the code out of the global.asa file and just put it in the first page of the site? I know that this would be admitting defeat but if you need a working version....
regards
jcd
|
|

11-07-2002, 01:05 PM
|
|
Centurion
|
|
Join Date: Apr 2002
Location: Newfoundland
Posts: 123
|
|
|
LOL, I was thinking of doing that but I just can't admit defeat LOL
What is really stumping me is it worked fine the first 2 weeks and starting yesterday this problem occurred and I really can't seem to give up on this, it is getting to me to the point that I cant even think of giving up and placing the code elsewhere. The thing that is driving me so crazy is it is just a basic write to database and why the session_OnStart is firing Twice and running the script twice got me mystified. I cannot give up this has got to be something simple that I am just over looking.
|
__________________
- - Renidragd - -
|

11-07-2002, 01:12 PM
|
|
|
What, if anything changed recently in your webserver config, updates,etc...
regards
jcd
The only way the session_OnStart can be called twice is if the webserver is creating as session then killing it right away and then creating a new session(you probably are well aware of this, just trying to work through bc you got me interested now 
|
Last edited by jcd; 11-07-2002 at 01:20 PM.
|

11-07-2002, 01:22 PM
|
|
Centurion
|
|
Join Date: Apr 2002
Location: Newfoundland
Posts: 123
|
|
|
That is the thing I am doing this for a friend and he has it hosted with a hosting service and the web server configurations are beyond my control but I am use to fooling with my own server here and I can not see what could effect the Session_OnStart and make it do this.
There is only one global.asa in the root of this site and there are no virtual sites within this site. So it is the only global.asa file for this asp application site.
|
__________________
- - Renidragd - -
|

11-07-2002, 01:25 PM
|
|
|
|
Well if the the webserver creates a session and then for some reason drops it and then creates another the session_onstart would be called twice....but why would the webserver do this everytime like clock work...regards
jcd
|
|

11-07-2002, 01:33 PM
|
 |
Contributor
|
|
Join Date: Oct 2002
Location: Virginia, USA
Posts: 716
|
|
|
Renidrag - out of curiosity...what hosting service is it?
|
__________________
I honestly think you ought to calm down; take a stress pill and think things over. - HAL 9000 (2001: A Space Odyssey)
|

11-07-2002, 01:41 PM
|
|
Centurion
|
|
Join Date: Apr 2002
Location: Newfoundland
Posts: 123
|
|
Is this Correct:
Global.asa --
Application_OnStart -------- Fires when server starts or restarts
Session_OnStart ------------ Fires when User first enters website
Session_OnEnd ------------- Fires when User Leaves website
Application_OnEnd --------- Fires when server is being shut down or restarted
I think I am getting somewhere just found out some thing that happens with the site when the TimeOut is fired.
I had just left the site alone while looking for some answers and when I went back in My Session had Expired so I hit refresh and then I checked my database records and noticed that from within the site when you refresh after your origianl session has expired the session_OnStart is called again to give you a new session ID but it only writes once to the database then so I check the existing records and found this to be true for the rest too, so I am off to check the first to pages of the site again.
Everyone I apologise I think I left out a crucial piece of information which is -- the site starts with index.htm and that is just a flash intro then the flash gets url home.htm which is a two frame document consisting of top.asp and bottom.asp and I think that is where my problem is occurring, I think it is like jcd said that :
Quote:
|
Well if the the webserver creates a session and then for some reason drops it and then creates another the session_onstart would be called twice....
|
|
__________________
- - Renidragd - -
|

11-07-2002, 01:42 PM
|
|
Centurion
|
|
Join Date: Apr 2002
Location: Newfoundland
Posts: 123
|
|
__________________
- - Renidragd - -
|

11-07-2002, 01:47 PM
|
|
|
|
Session_OnEnd
It is execute when a session is abandon of after certain period of time without contact between the client and the server (normaly after 20 minutes or so from the last request from a specific client, the server will consider he is not going to come back, so it will delete all the information related to that session).
Which explains what happened when you left the site alone
Regards
jcd
|
|

11-07-2002, 01:52 PM
|
 |
Contributor
|
|
Join Date: Oct 2002
Location: Virginia, USA
Posts: 716
|
|
Renidrag - Something you might want to add as a field in your database (for the purposes of troubleshooting) is the page that the record was generated from. Use Request.ServerVariables("SCRIPT_NAME") to get the filename of the page that fires the event. This might help you track it down...
edit: bah - never mind - I don't think you can use this in global.asa...guess you could try it though 
|
__________________
I honestly think you ought to calm down; take a stress pill and think things over. - HAL 9000 (2001: A Space Odyssey)
Last edited by Syko10-96; 11-07-2002 at 02:06 PM.
|

11-07-2002, 02:01 PM
|
 |
Contributor
|
|
Join Date: Oct 2002
Location: Virginia, USA
Posts: 716
|
|
__________________
I honestly think you ought to calm down; take a stress pill and think things over. - HAL 9000 (2001: A Space Odyssey)
|

11-07-2002, 02:09 PM
|
|
Centurion
|
|
Join Date: Apr 2002
Location: Newfoundland
Posts: 123
|
|
|
Actually, this is the first I have noticed this but my browser shows up as Netscape 4.00 and it isn't, I am using IE 6
|
__________________
- - Renidragd - -
|

11-07-2002, 02:48 PM
|
|
Centurion
|
|
Join Date: Apr 2002
Location: Newfoundland
Posts: 123
|
|
Syko10-96
The answer to my problem.
I had the top frame as top.asp and bottom frame as bottom.asp and I only change it yesterday so as to place some code in the top frame but change my mind and didn't put any code in after all but left the top frame as top.asp now i just changed it back to .htm and everything is purrrrrfect now.
thanks Syko10-96
|
__________________
- - Renidragd - -
Last edited by Renidrag; 11-07-2002 at 02:57 PM.
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|