Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss. print.
A VERY SIMPLE CA TUTORIAL

This is a very simple tutorial for using the CABuilder from https://www.foxite.com/downloads/default.aspx?id=161. Please follow along…

You need to have the NORTHWIND database set-up in SQLServer. If you don’t then just use the VFP upsize wizard to add it to the SQLserver.

1. Run the CABUILDER.PRG from within VFP



Change the fields so that it looks similar to above. The only difference should be the path settings for “folder for class lib”. Ignore the settings for STORED PROCEDURES.


2. Click “Build”
3. Select your server and click “Options”



4. Now select your database. This establishes the connection. Click OK and the builder goes to work.



5. When it has completed it will open the class in the Class Browser.



6. Close the class browser and create a new form.



7. Right Click on form and select “Data Environment” from the popup menu.



8. Do not open any tables so close the open tables dialog. Right click on the DE and select “Builder” from the popup



9. The VFP DE Builder will appear. Set the “Data source type” and the connection information. I prefer “Use connection string” as then I don’t need to set-up DSN’s on the computer. My connection string is shown.



10. Click “Test Connection” to test that you have properly set this up.



11. Click on the “Cursors” tab and click the “Add” button. Select the classlib created above and select a class – cacustomers.



12. Change the “Name” of the adapter just added. I use the convention as CA for the adapter and CRS for the cursor it creates. Also tick the “Use DataEnvironment data source” check box. Click OK. DON’T CLICK ON ANY OF THE OTHER TABS!!!



13. You will be returned to the screen with the adapter added showing. Click OK.




14. The CA has been added to the DE



15. Drag and drop it onto the form and VFP will create a Grid for it.



16. Run the form and it will be populated with the data from the SQL Server.



This concludes the tutorial.

I have developed a framework around these CA’s that I use. I have also modified the CA Builder so that it adds additional properties and code. If you open the _cabase class you will see FILLDATA() and SAVEDATA() as well as ConflictCheckCommand filled in. I have added these to suit my needs and this is autogenerated by the builder. I also extensively use SQLViews and have added this to the builder as well.

Hope this helps in understanding better and using CA’s without worrying about the 255 chr limit. I’d use this builder even with VFP9 as it saves me time by creating CA’s for all tables in a flash.

Included with this builder is the Classlib as well as the test form. I have also included the modified CABUILDER.PRG in the zip file. Changes are not all commented but can be found using a file compare program.

Download code
Click here to download the code that is discussed in this article. The download is a zipfile. Its size is 278,302 bytes.

ABOUT THE AUTHOR: BERNARD BOUT

Bernard Bout Bernard Bout is a long time member of the Foxite.COM Community and based in Brisbane, Australia. Bernard's weblog is here: http://weblogs.foxite.com/bernardbout/

FEEDBACK

@ 9/15/2007 8:04:21 AM
Update to get this to work:

The VFP CA Builder adds code to the Adapter that is not needed.

After step 15 above just open the CA just added and delete EVERYTHING from its AUTOUPDATE and INIT methods. Now run the form and it will work

Henry Pelausa @ 3/31/2012 8:50:38 AM
Sir Bernard
Just a quick question if I am already connected to the database and I want to see the content of specific table can I do it in the command window of VF issue a ' select * from xxxtable into cursor ycursor' then use the browse command, it will work?
Thanks
Henry



Your Name: 
Your Feedback: 

Spam Protection:
Enter the code shown: