Hi Shigang Zhang,
Be sure you have the latest OLE DB data provider, downloadable from msdn.microsoft.com/vfoxpro/downloads/updates, or ODBC driver, downloadable from msdn.microsoft.com/vfoxpro/downloads/updates/odbc . I recommend using OLE DB if at all possible.
The following connection strings work for me:
conn.Open "Provider = VfpOleDB.1;Data Source = D:\Temp;"
conn.Open "DSN=Visual FoxPro Tables;SourceDB=D:\Temp;SourceType=DBF;Collate=Machine;Exclusive=No;Deleted=Yes"
Please note that the Deleted setting is counterintuitive. "Yes" indicates to ignore deleted rows, which is probably what you want. You can refer to the tables in your select statement by their names and OLE DB or ODBC will look in the specified directory for them . Example: "Select * From MyTable"
Post back if you have any more trouble.
Cindy,
it's different now. After I changed the code to:
sCn = "Provider=VFPOLEDB.1;" & "Data Source=" & UCase(sSourceDb)
I recompiled the app and ran it my Win2K box, it worked. Then I run on my XP box vfpoledb.exe from the site you gave, which installed vfpoledb.dll version 9.0.0.3504. Then I installed the app on the XP box and ran. It gave me this error:
Error#: -2147221164, message: "class not registered".
Any idea?
Thanks a million - Shigang.
Hi Shigang,
Does it help to run RegSvr32 "C:\Program Files\Common Files\System\Ole DB\vfpoledb.dll" ?
Alternatively, here's a method outlined by Lee Mitchell:
1. Make copy of C:\Program Files\Common Files\System\Ole DB\vfpoledb.dll*
2. Go to Add/Remove programs, and uninstall Microsoft OLE DB Provider for Visual FoxPro
3. Move copy of vfpoledb.dll back to C:\Program Files\Common Files\System\Ole DB\, and make sure the filename is vfpoledb.dll.
4. Start/Run this: regsvr32 "C:\Program Files\Common Files\System\Ole DB\vfpoledb.dll"
* The disadvantage of this approach is it will also remove the C:\Program Files\Microsoft Visual FoxPro OLE DB Provider\ folder. This folder contains a Doc folder holding the helpfile dv_FoxProvider.chm and optionally a sample Northwind database in the Samples folder. If you wish to retain these, you would need to make a copy of the C:\Program Files\Microsoft Visual FoxPro OLE DB Provider\ folder before step 2 above.
Cindy,
thanks for your help. Somehow it still does not work. It gives the same error. I played register/unregister a little. If the DLL is registered, it would give the "Class not registered" error. If I unregister the DLL, it would give the "Provider cannot be found. It may not be properly installed" error.
One guy recommended on the web changing UserName in machine.config from "machine" to "system", which obviously worked for him on his XP box, but it does not work for me. Another guy recommended using vfp ole driver version 7.0, unfortunately I cannot find the 7.0 version driver.
Anyway, I am still looking for a solution. Your further will be appreciated.
Thanks - Shigang.
Cindy,
Don't worry about. Somehow I get it fixed. I simply recompiled the app in a different W2K machine with the same VB6 compiler (installed using the same CD). Now it has no more problem running. I have no idea why or how.
Thanks for your effort.
No comments:
Post a Comment