%
action = Request.QueryString("action")
SELECT CASE action
CASE "main"
DisplayMain
CASE "left"
DisplayLeft
CASE "deletedb"
DeleteFile(Session("dbPath"))
Response.Redirect "loaddb.asp"
CASE "loaddb"
Response.Redirect ("loaddb.asp")
CASE "createtable"
CreateTable
CASE "compactdb"
CompactDatabase
CASE Else
DisplayIndex
END SELECT
'****************************************************
'* This procedure is used for the frame of the index*
'****************************************************
Sub DisplayIndex
%>
<%
End Sub
Sub CreateTable
'Get name of new table
table = Request.Form("table")
If TableExists(table) = True Then
'Already exists, display error
strError = "Tabela ou campo já existente. Voltar" & _
" altere o nome."
ErrorMessage "Duplicidade", strError
JSGoBack(5)
Exit Sub
End If
'****************************************************
'* Passed existance check, now create the table *
'****************************************************
strQuery = "CREATE TABLE [" & table & "]"
db.Query(strQuery)
'****************************************************
'* Close all database connections *
'****************************************************
IncludeBottom
'****************************************************
'* Refresh index page to show new table *
'****************************************************
Response.Redirect "index.asp"
End Sub
'// Routine used to compact a database
Sub CompactDatabase
On Error Resume Next
'// Close database connection
db.objConn.Close
'// Create Jet Engine object
Dim objJetEngine
Set objJetEngine = server.createobject("jro.JetEngine")
'// Get old database path
temp = Replace(Session("dbPath"), "/", "\")
If Right(temp, 1) = "\" Then temp = Left(temp, Len(temp)-1)
temp = Split(temp, "\")
database = Replace(Session("dbPath"), temp(UBound(temp)), Empty)
database = Replace(database, "/", "\")
If Right(database, 1) <> "\" Then database = database & "\"
'// Delete any temporary database
Set objFSO = Server.CreateObject ("Scripting.FileSystemObject")
If objFSO.FileExists(database & "temp.mdb") = True Then
'// Delete file
objFSO.DeleteFile database & "temp.mdb"
End If
'// Compact database
objJetEngine.CompactDatabase db.objConn, _
"Provider=MICROSOFT.JET.OLEDB.4.0; DATA SOURCE=" & database & "temp.mdb;"
'// Delete original database
objFSO.DeleteFile Session("dbPath")
'// Rename temp database back to original
objFSO.MoveFile database & "temp.mdb", Session("dbPath")
'// Destroy Jet Engine object
Set objJetEngine = Nothing
'// Destroy FSO object
Set objFSO = Nothing
'// Check for any errors
If Err.number > 0 Then
SQLError Err.number, Err.Description, Err.Source, "Compactando database..."
Exit Sub
End If
On Error GoTo 0
'// Redirect back to index
Response.Redirect "index.asp?action=main"
End Sub
'****************************************************
'* Call ending tasks procedure *
'****************************************************
IncludeBottom
%>