DNS DB Connection Guard
I have a website with ASP VBScript.
However I'm continually having to add new tables and queries to my database.
Now, this can cause problems since it's in use.
I would like an extention that can see if the database is in use (ie being uploaded or downloaded) and redirect the website visitor to a new page, say tempunavailble.htm or whatever you specify. That way the DNS won't get messed up when someone tries to open a page and your uploading or downloading the DB.
Comments
re: dns db...
Now that's a simple request.
Here's what you do. This may work for dsn.s but again dsn's are not considered fast.
I suggest you use Microsoft Jet OLEDB. Example below.
Dim strSite
strSite = strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("_db/pacific.mdb") & ";User id=";Password"=;"
The above is your connection file which will be an include file.
1. Create a file called lock.asp "or anything you desire"
2. Creat a table called dblock and a yes/no field called lock which is a checkbox.
3. Now the script will look as follows :-
<!-- #INCLUDE FILE="dbconn.asp" -->
<%@ language="VBScript" %>
<%
Option Explicit
Response.Expires = 0
Dim strSite
Dim rs
Dim con
Set con = Server.CreateObject("ADODB.Connection")
con.Open strSite
Set rs = Server.CreateObject("ADODB.Recordset")
rs.ActiveConnection = strSite "for ud users."
Dim isLocked
If CBool(Request.QueryString("lock")) Then
con.Execute "INSERT INTO dblock VALUES (True);"
isLocked = True
Else
con.Execute "DELETE FROM dblock;"
End If
If isLocked Then
Response.redirect "locked.asp"
Else
Response.redirect "index.asp"
' which is the main page on your site or if you have your site
' setup like mne as a header include file."
End If
Response.End
%>
I hope this answers your request.
Errors
I had to delete the <%@ language="VBScript" %> as I already have @ in it already.
Now I get this error:
Microsoft VBScript compilation error '800a0400'
Expected statement
/index.asp, line 812
You must me logged in to write a comment.