Hi all my friends,
Obviously, Dave was reading about ADO from MSDN or any book, unfortunately these resources focus on VB not VFP. The major deference is that VB support a technology called Intellisense
Which means that, when you define a variable AS <Object> like that
– by the way such a declaration is known as early binding because you early bind you variable to a specific type of objects - VB Intelligently sense that you want to use ADO object so it automatically opens the suitable header file which includes –beside other things-all the constant values like “adStateConnecting” which by the way = &H00000002 . So when you code in VB something like
Code:
If CN.State = adStateOpen Then MsgBox "Connection OK."
the compiler is perfectly happy because the variable adStateOpen is already predefined. Unfortunately all the resources forgot about the FoxPro programmers –as usual – and they forgot that we don’t enjoy having Intellisense in VFP.
But we have #Include directive which VB doesn’t have yet. So the game is very simple, find the Type library file, extract all the constants values, write them to .h file with #DEFINE preceding each value then include this file in your project, the compiler will be happy.
Well, Rick Strahl -in his company’s web site
- submitted a free program called getconstants.EXE. This program is designed to do exactly what I was talking about in the previous paragraph. The input for this program is your Type Library File for the object you want to use and the out put is .H version to include with your VFP project. To download this program go to
scroll all the way down in the main page until you see the link “Shareware and Free Software “.
Select “Visual FoxPro Internet Tools” Click “GetConstants – Grab TypeLib constants to header files”.
Download wwTypeLib.zip. Extract it to any directory you like, now you are ready to use getconstants.EXE
When you run this program it will ask you to provide a source type library file.
Most of the type library files has the extension .OLB or .TLB.
So, before you wonder how you will know where is this file, you can just do like me and use the wonderful tool FIND FILES OR FOLDERS and type *few characters from you r object name* for example to find this one I used *ADO*, then I made a good guess with the file
“msado21.tlb”. Give this file to getconstants.EXE in a second you will have a header version of it ready to use and don’t worry about any thing else. Now just include this file in your program and use all the constants with their name not values and your compiler will be happy.
Don’t try to point to ADOVBS.INC as a source file for this program, this will cause an "OLE IDispatch exception code 0" error and the program will shut down. ADOVBS.INC is not a valid Type Library File it just has the constants required by VBScript language but it is not the type library file for the ADO COM Object. Also don’t worry about replacing &H with 0X. Rick didn’t forget anything – I will be amazed if he did - just trust that your header file is ready to use don’t worry about the details
Hope this will help all my friends understand what is this Intellisense and how can we overcome not having it in VFP.
Thanks
Walid Magd
Engwam@Hotmail.com