Open a windows database file with a path name?

waldekO osuchw at ecn.ab.ca
Sat Nov 10 10:59:22 CET 2001


Nomad <nomad***@***freemail.absa.co.za> wrote in message news:<qnonuto5ao5iu4c0fa1ttletlje3s9sfck at 4ax.com>...
> Hi,
> 
> Is there anyway that I can open a database (MSAccess in this case)
> using the path and file name rather than a DSN?  I can't seem to get
> it to work.
> 
> TIA

try this:

>>> from win32com.client import Dispatch, constants
>>> eng = Dispatch('DAO.DBEngine.36')
>>> db = eng.OpenDatabase('c:/db1.mdb')
>>> rs = db.OpenRecordset('select * from tblHolidays')
>>> rs.Fields('ID').Value
1
>>> rs.MoveNext()
>>> rs.Fields('ID').Value
2



More information about the Python-list mailing list