Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Exception occurred.
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Exception occurred.

 Post Reply Post Reply
Author
skyworld View Drop Down
Senior Member
Senior Member


Joined: 12 December 2002
Location: United States
Status: Offline
Points: 134
Post Options Post Options   Thanks (0) Thanks(0)   Quote skyworld Quote  Post ReplyReply Direct Link To This Post Topic: Exception occurred.
    Posted: 23 February 2003 at 10:30am

can some one please help me with this code im trying to get here.. I am having it so when someone visits my site it checks for a ip and ads it to the database. I think my main problem here is my sql entry though because its made for if a ip already exists...

error '80020009'

Exception occurred.

/Default.asp, line 10

My code:

<!--#include virtual="include/database/connect.asp"-->
<%
'Ip logger/blocker
Dim IPADDRESS

IPAddress = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If IPADDRESS = "" Then IPADDRESS = Request.ServerVariables("REMOTE_ADDR")
strSQL = "SELECT * From ip where ip like '" & IPADDRESS & "'"
rsportal.Open strSQL, adoCon
if rsportal("ip") = "" then
rsportal.AddNew
rsportal.Fields("ip") = IPADDRESS
rsportal.Fields("log") = "0"
rsportal.fields("lastvisit") = formatdate(strdate, 0) & " @ " & time()
rsportal.fields("blocked") = FALSE
rsportal.Update
else

Do while not rsportal.eof
rsportal("log") = rsportal("log") + 1
rsportal("lastvisit") = formatdate(strdate, 0) & " @ " & time()
loop

end if

if rsportal("blocked") = TRUE then
response.redirect "banned.asp"
else
%>
<META HTTP-EQUIV="REFRESH" CONTENT="3; URL=index.asp">
<%
end if
if rsportal("theme") = "" then
rsportal("theme") = "default"
%>
<link rel="stylesheet" href="theme/<%=rsportal("theme")%>/style.css" type="text/css">
<%
else
end if
Set rsportal = Nothing
%><!--#include virtual="include/database/disconnect.asp"-->

Back to Top
skyworld View Drop Down
Senior Member
Senior Member


Joined: 12 December 2002
Location: United States
Status: Offline
Points: 134
Post Options Post Options   Thanks (0) Thanks(0)   Quote skyworld Quote  Post ReplyReply Direct Link To This Post Posted: 23 February 2003 at 10:31am

O sorry...

Connect:

<%
Dim adoCon   'Holds the Database Connection Object
Dim rsportal   'Holds the recordset for the records in the database
Dim SQL  'Holds the SQL query for the database
Dim dbloc
dbloc = "fpdb/sky.mdb"
Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath(dbloc)
Set rsportal = Server.CreateObject("ADODB.Recordset")
%>

 

Disconnect:

<%
Set adoCon = Nothing
%>

 

Back to Top
MadDog View Drop Down
Mod Builder Group
Mod Builder Group
Avatar

Joined: 01 January 2002
Status: Offline
Points: 3008
Post Options Post Options   Thanks (0) Thanks(0)   Quote MadDog Quote  Post ReplyReply Direct Link To This Post Posted: 23 February 2003 at 12:19pm

this isnt the problem but you should close your connections all the way

<%
rsPortal.Close
Set rsportal = Nothing
adoCon.Close
Set adoCon = Nothing
%>

Back to Top
skyworld View Drop Down
Senior Member
Senior Member


Joined: 12 December 2002
Location: United States
Status: Offline
Points: 134
Post Options Post Options   Thanks (0) Thanks(0)   Quote skyworld Quote  Post ReplyReply Direct Link To This Post Posted: 23 February 2003 at 12:56pm

ok

Back to Top
skyworld View Drop Down
Senior Member
Senior Member


Joined: 12 December 2002
Location: United States
Status: Offline
Points: 134
Post Options Post Options   Thanks (0) Thanks(0)   Quote skyworld Quote  Post ReplyReply Direct Link To This Post Posted: 23 February 2003 at 1:04pm
i think the problem is that i have the sql querry looking for a record that has not been created yet... How do i create it if its not there?
Back to Top
skyworld View Drop Down
Senior Member
Senior Member


Joined: 12 December 2002
Location: United States
Status: Offline
Points: 134
Post Options Post Options   Thanks (0) Thanks(0)   Quote skyworld Quote  Post ReplyReply Direct Link To This Post Posted: 23 February 2003 at 1:09pm

btw this is line 10 i think...

if rsportal("ip") = "" then

Back to Top
skyworld View Drop Down
Senior Member
Senior Member


Joined: 12 December 2002
Location: United States
Status: Offline
Points: 134
Post Options Post Options   Thanks (0) Thanks(0)   Quote skyworld Quote  Post ReplyReply Direct Link To This Post Posted: 23 February 2003 at 6:22pm

i managed to get it to add and update but the problem i am getting now is it doesnt update to that field instead it adds it again. ...

 

my new code :)

 

<%
Dim adoCon   'Holds the Database Connection Object
Dim rsportal   'Holds the recordset for the records in the database
Dim SQL  'Holds the SQL query for the database
Dim dbloc
dbloc = "fpdb/sky.mdb"
Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath(dbloc)
'-------------------------------------------------------------------------------------
'IP LOGGER
Dim ipaddress
ipaddress = request.servervariables("http_x_for")
if ipaddress <> "" then
ip = ipaddress
else
ip = request.servervariables("remote_addr")
end if
if len(ip) > 0 then
Set rsportal = Server.CreateObject("ADODB.Recordset")
strsql = "select * from ip;"
rsportal.CursorType = 2
rsportal.LockType = 3
rsportal.open strsql, adocon

rsportal.addnew
rsportal.fields("ip") = ip
rsportal.fields("log") = "1"
rsportal.fields("lastvisit") = now()
rsportal.fields("blocked") = false
rsportal.fields("theme") = "default"
rsportal.update
end if
if err.number <> 0 then
strsql = "select * from ip where ip like '" & ip & "'"
rsportal.open strsql, adocon
rsportal("log") = rsportal("log") + 1
rsportal("lastvisit") = now()
end if
if rsportal("blocked") = true then
response.redirect "banned"
else
%>
<meta http-equiv="refresh" content="3; url=index.asp">
<link rel="stylesheet" href="theme/<%=rsportal("theme")%>/style.css" type="text/css">
<%
end if
rsportal.close
adoCon.Close
set rsportal = nothing
Set adoCon = Nothing
%>

Back to Top
skyworld View Drop Down
Senior Member
Senior Member


Joined: 12 December 2002
Location: United States
Status: Offline
Points: 134
Post Options Post Options   Thanks (0) Thanks(0)   Quote skyworld Quote  Post ReplyReply Direct Link To This Post Posted: 23 February 2003 at 6:24pm

pretty much it ads it instead of checking if its there and updating ...



Edited by skyworld
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.