Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ADO - Recordset.Find() problem
Message
From
02/11/1999 18:13:47
 
 
To
02/11/1999 17:52:58
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Miscellaneous
Thread ID:
00285771
Message ID:
00285822
Views:
12
>>I am trying to use ADO as a substitute for VFP remote views for data entry. All of the textbox controlsources will point to the form's ADO recordset object (ex: "thisform.ors.fields('vendornum').value" ). So far the form instantiates fine, the recordset objects gets created and loaded, and I can navigate top/bottom/next/previous using the native recordset methods. But when I try to do a Find() I get the following error:
>>
>>"OLE IDispatch exception code 0 from ADODB.Field: Either BOF or EOF is True, or the current record has been deleted; the operation requested by the application requires a current record..."
>>
>>The error SEEMS to be related to binding the recordset to controls (that's my SWAG, anyway). Does anyone have any experience with doing this? FYI I'm trying this with a dynamic server-side cursor; I tried the same thing with a static cursor with the same results.
>>
>>Any help will be greatly appreciated.
>You should bookmark the current record before doing a find and if the search criteria is not met then go back to that record. If there is no match the record pointer goes to EOF and you know what happens after that.
>
>myBookM = oRS.Bookmark
>thisform.oRS.MoveFirst
>thisform.oRS.Find "description Like '" + Alltrim(myCriteria) + "*'"
>If thisform.oRS.EOF Then
>    MessageBox("No matches with this criteria")
>    thisform.oRS.Bookmark = myBookM
>End If
>PS Note that not all ADO cursor types support bookmarks or the .Movefirst method.

Thanks but that wasn't the problem. I just found it (to my chagrin). To do the search, I first built a string:

lcSearchString = ALLTRIM(lcSearchField) + " = '" + ALLTRIM(lcSearchVal) + "'"

then do the find:

ThisForm.oParent.oRS.Find(lcSearchString)

But in the original I had the single/double quotes backwards:

lcSearchString = ALLTRIM(lcSearchField) + ' = "' + ALLTRIM(lcSearchVal) + '"'

It was simply a matter of syntax.

FOR i = 1 to 3
Dan LeClair
www.cyberwombat.com
SET RANT ON - The Wombat Blog

Life isn’t a morality contest and purity makes a poor shield. - J. Peter Mulhern
Disclaimer: The comments made here are only my OPINIONS on various aspects of VFP, SQL Server, VS.NET, systems development, or life in general, and my OPINIONS should not be construed to be the authoritative word on any subject. No warranties or degrees of veracity are expressed or implied. Void where prohibited. Side effects may included dizziness, spontaneous combustion, or unexplainable cravings for dark beer. Wash with like colors only, serve immediately for best flavor.
Previous
Reply
Map
View

Click here to load this message in the networking platform