Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Elson Miranda
  Where is Elson Miranda?
 Elson Miranda
Subject: ADO error!
Thread ID: 104492 Message ID: 104492 # Views: 6 # Ratings: 0
Version: Visual FoxPro 9 Category: Errors & Debugging
Date: Thursday, August 17, 2006 2:15:25 AM         


I’ll try this code below taken from VFP and ADO PART2 of SimonsArnold. When I change the table name into long filename from ACCESS ex.“Customer” table into “Customer File”, I’ve got this error message: Invalid sql statement; expected ‘DELETE’, ‘INSERT’, ‘PROCEDURE’, ‘SELECT’, or ‘UPDATE’.

*-- Add two new properties to the form and create the ADO Objects.
.AddProperty('oCN',CREATEOBJECT('ADODB.Connection') )
.AddProperty('oRS',CREATEOBJECT('ADODB.RecordSet') )

*-- Create a DSN-Less Connection to the Access Database.
.oCN.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Test.mdb"

IF .oCN.State = 1 && If Connection is fine, create RecordSet
.oRS.ActiveConnection = .oCN
.oRS.CursorType = adOpenKeySet && Constant in adovfp.h
.oRS.LockType = adLockOptimistic && in adovfp.h - Record Locking Method
.oRS.Open("Customers File")
.txtRecCount.Value = .oRS.RecordCount && Display Number of Records
.oRS.MoveFirst && Start At the Top of the File

*-- Populate the Fields on Screen
THISFORM.DisplayFields( .oRS )


ADO error! Posted by Elson Miranda @ 8/17/2006 2:15:25 AM