Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adodatacontrol ERROR!! 1

Status
Not open for further replies.

Guntruck

Programmer
Mar 29, 2001
25
US


When I try to do a ThisForm.Adodatacontrol1..refreshrecordset

I get a error saying adStateConnecting doesnt exist...
here the code from the ADOdatacontrol object...

any ideas why?? bad connection string? I'm lost here guys..

*-- Loop until we connect
DO WHILE This.Connection.State = adStateConnecting
ENDDO



Dave
 
re: adStateConnecting

Where is a value assigned to 'adStateConnecting'? If it's in a function elsewhere, it might just be a local variable and not available. If it's a property of the control, I'd assume you'd need to have something like .adStateConnecting. --Dave
 

Its not a property of the control. Thats why im confused. If it was ied just set it. In the example for this control it says nothing bout it. and i searched for the variable/property and found little about it. Im confused.



dave
 
Hi!

adStateConnecting is a constant defined for ADO modules. Look to help for their values. You should define it by using #DEFINE directive before use, use header file with constants definitions for ADO (*.h file) if you have such for VFP, or just replace it in the code by using its numeric value. The best way, of course, is to get header file, because you will be able to use all other ADO constants this way.

Vlad Grynchyshyn
vgryn@softserve.lviv.ua
The professional level of programmer could be determined by level of stupidity of his/her bugs
 
Thats what I figured.. now if I could only find the header.. hmm


dave
 
Hi Dave,

1. Look in your Program Files\Common Files\System\ADO directory for a file named adovbs.inc. It's the ADO constants header file for VBScript.

2. Look in your VFP\Tools\XSource directory for a file named XSource.zip. Extract the contents. Search for a file named adovfp.h.

3. Download Rick Strahl's type library parser from UniversalThread.com, named GetConstants - COM Constants to Header File. Use it.

If you elect to use methods 1 or 2, open the file and replace all &H occurences with 0x. These are hexadecimal values. Jon Hawkins

The World Is Headed For Mutiny,
When All We Want Is Unity. - Creed
 
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
Code:
 Dim CN As Connection
– 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 &quot;Connection OK.&quot;
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 &quot;OLE IDispatch exception code 0&quot; 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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top