2
votes

i dont have microsoft access but would like to open an mdb file, is there any way to do this?

the mdb file contains SQL code that i need. it is just a file that connects to a remote database. i need to view the sql code

i did try openoffice base, but it only showed me some tables. i dont see where the sql code is?

5
What do you mean by SQL Code? Access Queries?DJ.

5 Answers

5
votes

This VBScript will print out the SQL statements from the saved queries in your MDB database.

Option Explicit
Dim dbe
Dim db
Dim qdf

Set dbe = CreateObject("DAO.DBEngine.36")
'change the next line to include the full path to your database
Set db = dbe.OpenDatabase("C:\SomeFolder\YourDatabase.mdb")
For Each qdf In db.QueryDefs
    If Left(qdf.Name,1) <> "~" Then
        Wscript.StdOut.WriteLine qdf.Name
        Wscript.StdOut.WriteLine qdf.SQL
        Wscript.StdOut.WriteLine String(20, "-")
    End If
Next
Set db = Nothing
Set dbe = Nothing

I saved it as DumpQuerySQL.vbs, then ran it from a command prompt like this:

cscript DumpQuerySQL.vbs > querySQL.txt
2
votes

"Accessing" it through ADO.NET and virtually anything else should do the trick.

Kindness,

Dan

1
votes

The Jet driver included with most versions of Windows can do this. You can use the Jet driver through your prefered provider or API (ODBC, ADO, ADO.NET). Even Excel supports it (Open file, and choose MDB).

1
votes

visual studio is able to view and modify access databases via its datasources features.

You might also want to check out FlySpeed SQL Query, which can query all kinds of databases "on the fly"

0
votes

Have you tried openoffice base? I've had good luck with that converting MDB files.