views:

478

answers:

5

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?

+2  A: 

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

Kindness,

Dan

Daniel Elliott
VBScript, C#, JavaScript etc
Daniel Elliott
+1  A: 

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).

David
It's in MDAC. MDAC can be installed seperately
Lars Truijens
Jet has not been included in MDAC for many years -- it doesn't need to be, since it's been part of Windows since the release of Win2000.
David-W-Fenton
A: 

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"

Johannes Rudolph
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__
A: 

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

Peter Turner
updated, thank you
I__
+4  A: 

You didn't mention which Windows MDAC version you have. This script will print out the SQL statements for saved queries in your database, if your MDAC version supports DAO 3.6

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
HansUp
MDAC has nothing to do with it. Jet 4.0 is part the OS and DAO is included by default. OLEDB may be a better choice depending on your development platform, though. Your code is good, though. +1
David-W-Fenton
I misinterpreted what I read about MDAC 2.8 then. From your comment, it sounds like I can still rely on DAO for Vista and Win7 machines without Access. I like that.
HansUp
HansUp. Jet 4.0/DAO still exists as part of the OS in Vista and Win 7.
Tony Toews
Thanks, Tony. That's what I inferred; I appreciate the confirmation.
HansUp
The SQL code that defines a CHECK constraint cannot be extracted using DAO ;)
onedaywhen
@onedaywhen Please elaborate. I don't see how CHECK constraint is relevant here.
HansUp