CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> General/Other

 COMPACT AND REPAIR - ACCESS MDB - USING ASP

Print topic Send  topic

Author Message
Navneet Kakkar
Posted: 04/03/2004, 11:44 PM

is there any command to run the compact and repair database command of
access.

i am using ASP.
--
Thanks

luv

Navneet
aquananu@yahoo.com
9811153443


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.644 / Virus Database: 412 - Release Date: 3/26/2004

navcan

Posts: 61
Posted: 07/16/2004, 8:04 AM

I am also looking for similar solution from within ccs. Also would like to have only Administrator perform compact and repair.

Any suggestions or solution?
View profile  Send private message
dataobjx


Posts: 181
Posted: 07/16/2004, 8:31 AM

Try This...

<%

Const Jet_Conn_Partial = "Provider=Microsoft.Jet.OLEDB.4.0; Data source="
Dim strDatabase, strFolder, strFileName

'#################################################
'# Edit the following two lines
'# Define the full path to where your database is on the server
strFolder = "c:\2\"
'# Enter the name of the database
strDatabase = "Internet_Test.mdb"
'# Stop editing here
'##################################################

Private Sub dbCompact(strDBFileName)
Dim SourceConn
Dim DestConn
Dim oJetEngine
Dim oFSO

SourceConn = Jet_Conn_Partial & strFolder & strDatabase
DestConn = Jet_Conn_Partial & strFolder & "Temp" & strDatabase

Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
Set oJetEngine = Server.CreateObject("JRO.JetEngine")

With oFSO

If Not .FileExists(strFolder & strDatabase) Then
Response.Write ("Not Found: " & strFolder & strDatabase)
Stop
Else
If .FileExists(strFolder & "Temp" & strDatabase) Then
Response.Write ("Something went wrong last time " _
& "Deleting old database... Please try again")
.DeleteFile (strFolder & "Temp" & strDatabase)
End If
End If
End With

With oJetEngine
.CompactDatabase SourceConn, DestConn
End With

oFSO.DeleteFile strFolder & strDatabase
oFSO.MoveFile strFolder & "Temp" _
& strDatabase, strFolder& strDatabase

Set oFSO = Nothing
Set oJetEngine = Nothing
End Sub

Private Sub dbList()
Dim oFolders
Set oFolders = Server.CreateObject("Scripting.FileSystemObject")
Response.Write ("<Select Name=""DBFileName"">")
For Each Item In oFolders.GetFolder(strFolder).Files
If LCase(Right(Item, 4)) = ".mdb" Then
Response.Write ("<Option Value=""" & Replace(Item, strFolder, "") _
& """>" & Replace(Item, strFolder, "") & "</Option>")
End If
Next
Response.Write ("</Select>")

Set oFolders = Nothing
End Sub


%>
<%
' Compact database and tell the user the database is optimized
Select Case Request.form("cmd")
Case "Compact"
dbCompact Request.form("DBFileName")
Response.Write ("Database " & Request.form("DBFileName") & " is optimized.")
End Select
%>

<p><font size="4">Compact and repair database</font></p>
<form method="POST" action="">
<p><%dbList%><input type="submit" value="Compact" name="cmd"></p>
</form>

_________________
www.DataObjx.net
www.mydigitalapps.com
View profile  Send private message
dataobjx


Posts: 181
Posted: 07/16/2004, 8:32 AM

P.S.

You need to have a \temp folder under the db directory ....

note the line that says...

DestConn = Jet_Conn_Partial & strFolder & "Temp" & strDatabase
_________________
www.DataObjx.net
www.mydigitalapps.com
View profile  Send private message
kd5jnx

Posts: 5
Posted: 09/15/2004, 9:16 AM

Where would I place this? I got an error when copying and pasting.

For Each Item In oFolders.GetFolder(strFolder).Files

that was the line i got an error on
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.