|
rdouglass -> RE: Using too Many Server Resources??? (9/2/2005 9:35:58)
|
I think you can do something here. How about something like this: If Not Response.IsClientConnected Then
Response.End
Else
On Error Resume Next
sDatabase=Server.Mappath("fpdb/main.mdb")
sSQL = "INSERT INTO redirect (URL,IP_Address,Timestamp) VALUES ('" & Request.QueryString("VendorHomepage") & "','" & Request.QueryString("REMOTE_HOST") & "',#" & dateadd("H",+3,now()) & "#)"
Set oConnection = CreateObject("ADODB.Connection")
sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("fpdb/main.mdb")
oConnection.Open sConnection
oConnection.close
Set oConnection=Nothing
End If
...for the database writes? I say this 'cause I don't really understand why you have an FSO in there to check for the DB file existence. Does it change regularly? If so, have it check at first entry or even apllication launch, not every time you write a new log item. At least IMO. Also, why the 2 different recordset connections? Aren't you just writing a little record? If you need to identify the user, how 'bout a quick login and then use a cookie or session variable for a value? To me it seems like a lot of extra db hashing. Lastely, yes I'd consider the redirect section a candidate for a CASE statement. Maybe something like: <% IF request.servervariables("REMOTE_ADDR") > "" THEN myTempArray = split(request.servervariables("REMOTE_ADDR"),".") CASE (myTempArray(0) & "." & myTempArray(1)) CASE "66.196","68.142"",216.117","65.54","212.227" Response.redirect(url) END SELECT END IF%> I'm guessing what you want is to not record any activity from those subnets. By "split"ting the IP, we don't have to worry about string length and all those different IF...THEN's. That might be some of the performance issue but I think the first one is more important. SO if it were me, I'd probably attempt to reduce the code down to something like this: <% Request.QueryString("VendorHomepage")
URL=Request.QueryString("VendorHomepage")%>
<%
Dim adCmdText
Dim sDatabase
Dim oFSO
Dim oConnection
Dim sSQL
Dim oCommand
Dim rsResults
Dim sConnection
IF request.servervariables("REMOTE_ADDR") > "" THEN
myTempArray = split(request.servervariables("REMOTE_ADDR"),".")
CASE (myTempArray(0) & "." & myTempArray(1))
CASE "66.196","68.142"",216.117","65.54","212.227"
Response.redirect(url)
END SELECT
END IF
If Not Response.IsClientConnected Then
Response.End
Else
On Error Resume Next
sDatabase=Server.Mappath("fpdb/main.mdb")
sSQL = "INSERT INTO redirect (URL,IP_Address,Timestamp) VALUES ('" & Request.QueryString("VendorHomepage") & "','" & Request.QueryString("REMOTE_HOST") & "',#" & dateadd("H",+3,now()) & "#)"
Set oConnection = CreateObject("ADODB.Connection")
sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("fpdb/main.mdb")
oConnection.Open sConnection
oConnection.close
Set oConnection=Nothing
End If
Response.Redirect URL
%> One biggie IMO is to be sure and do things only when necessary. If you need to check for the existence of the DB file, do it once per user session at maximum. Definitely not everytime you access the db. If you *have* to check every time, I'd suggest Access is *not* the solution for you.[;)] Another one is don't use the recordset object to write to the DB. Build your SQL string and then open run the sql and close the session. Using Addnew - Fields - Update - Close IMO is just too much overhead for these simple writes. That any help?
|
|
|
|