Reputation: 60871
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?
Upvotes: 2
Views: 3112
Reputation: 97131
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
Upvotes: 5
Reputation: 11435
Have you tried openoffice base? I've had good luck with that converting MDB files.
Upvotes: 0
Reputation: 35761
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"
Upvotes: 1
Reputation: 25470
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).
Upvotes: 1
Reputation: 22887
"Accessing" it through ADO.NET and virtually anything else should do the trick.
Kindness,
Dan
Upvotes: 2