views:

329

answers:

2

I have a connection to an access database that implements MSDataShape that works perfectly on Windows XP, now when i try to run it on Windows Vista it game me an error.

The error on vista error:

Error # -2147467259

[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

The same code works perfectly in a clean xp instalation.

What's the big secret?

A: 

I tested this on Vista and Access 2000, and it worked for me. I have the latest Jet version, which should install with Vista.

Private Sub Form_Open(Cancel As Integer)
    Set cn = New ADODB.Connection
    With cn
        .Provider = "MSDataShape"
        .CursorLocation = adUseClient
        .ConnectionString = "DATA PROVIDER=Microsoft.Jet.OLEDB.4.0;" _
         & "DATA SOURCE=c:\docs\ltd.mdb"
        .Open
    End With

    Set rs = New ADODB.Recordset

    With rs
        .Source = "SELECT * From Table1"
        .ActiveConnection = cn
        .CursorType = adOpenKeyset
        .LockType = adLockOptimistic
        .Open
    End With

    Set Me.Recordset = rs
    Me.UniqueTable = "Table1"

End Sub

References: http://support.microsoft.com/kb/227053/EN-US/ http://support.microsoft.com/kb/239114/en-us

Remou
A: 

A few of things to check:

  • you're using ODBC, are you sure the exact same ODBC data source that you use on the XP machine was created?

  • If you're on 64 bit OS, you need to create a 32 bit ODBC Data Source, the 64 bit ODBC Data Sources are invisible to Access which is a 32 bit app.

  • Make sure you have the right Jet database drivers installed. If you use Access 2007, these would be the Access Database Engine component.

Renaud Bompuis
In regard to the last one, that's only essential if your "Access" file is an ACCDB and not an MDB. An MDB created in A2K7 will be completely accesible via the Jet 4 ODBC driver.
David-W-Fenton