Software Technology Tips

Create MDB database using ASP/VBScript:

There are two ways to create MDB database using VBScript.

1. Create MDB by ADO (ADOX):

The following code is for creating a new Access2000 database by ADO and for the code to execute MDAC2.0 is required to be installed in the machine.

 

const jet4x = 5

DoCreateNewMDB "F:\MyAccessDB2000.MDB", Jet4x

Sub DoCreateNewMDB(FileName, Format)

Dim Catalog

Set Catalog = CreateObject("ADOX.Catalog")

Catalog.Create "Provider=Microsoft.Jet.OLEDB.4.0;" & _

"Jet OLEDB:Engine Type=" & Format & _

";Data Source=" & FileName

End Sub

Compact (compress) MDB database using ASP/VBS script.

We can compact MDB database directly from the ASP (VBS) by DAO or JRO.

1. Compact MDB by DAO Engine:


The following code need DAO 3.5 to be installed in machine.

Dim Engine

Engine.CompactDatabase "F:\Database.mdb", "F:\Compacted_Database.mdb"

Set Engine = CreateObject("DAO.DBEngine.35")

 

2.Compact MDB by JRO Engine:

The following code need MDAC 2.1 to be installed in machine.

Dim Engine

Set Engine = CreateObject("JRO.JetEngine")

Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\Database.mdb", _ "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\Compacted_Database.mdb"

Neither DAO nor JRO allow you to compress and replace existing file on the fly. So we need to create a temporary compacted database and then copy the temporary file over the original database"

Convert MDB database to another format(JET,access conversion) using ASP/VBScript:

We can convert the MDB database to another format by using the following VB script.

Let's assume F:\MyDB97.MDB is the source database which needs to be converted to the database F:\MyDB2000.MDB

const jet4x = 5

DoConvertMDB "F:\MyDB97.MDB", "F:\MyDB2000.MDB", Jet4x

Sub DoConvertMDB(SourceDB, DestDB, Format)

Dim Engine

Set Engine = CreateObject("JRO.JetEngine")

Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & SourceDB, _

"Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=" & Format & ";Data Source=" & DestDB

End Sub


Related Tags:

MS Access, ADO, ASP/VBS

Author: Tapaswini Mohanty

Related Pages

  • MS Access Development Skill
  • Access Database Projects

Miscellaneous

Let us Connect!

Awards and Achievements

Red Herringcolor DeloitteFast50 DB ZInnov1   Nascome

Events

serf DDM

This site uses cookies. We respect your privacy.copyright (c) Mindfire Solutions 2007-2015. Login