Can DAO access schemas in current Sql Server versions?
We have an app we maintain which is written in VB6 and uses the prehistoric DAO technology to do its database access. The database is in Sql Server 2008.
We are writing a new module now, that I wanted to logically separate off with its own schema. However when I try to write a simple select query like:
SELECT ROWID, NAME FROM exports.TYPES ORDER BY NAME
DAO is complaining:
Error # 3024
Couldn't find file 'C:\Program Files\Microsoft Visual Studio\VB98\exports开发者_开发技巧.mdb'.
So clearly, DAO is interpreting the schema as a different database... is there any way to tell it to just pass the query through to the Sql Server?
This app is NOT using Access at all, just the DAO libraries.
Grrr... after googling for a half-an-hour, and then finally deciding to post a Q, then I try one more google and find the answer. Sheesh! I hate when that happens!
Anyway, here is the answer for those who may need it in the future.
I had to change my OpenRecordset
statement from this:
Set rs = db.OpenRecordset(SQL, dbOpenSnapshot, dbSeeChanges)
to this:
Set rs = db.OpenRecordset(SQL, dbOpenSnapshot, dbSeeChanges Or dbSQLPassThrough)
Answer is from this KB on ms.com.
精彩评论