Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ADO and CursorAdapter - letting ADO do the work?
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
ADO and CursorAdapter - letting ADO do the work?
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows Server 2003
Network:
Windows 2000 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
00973485
Message ID:
00973485
Views:
65
Hi all,

Another question about the CursorAdapter. My main goal here is for building a data adapater that simulates what SQL Passthrough does with ADO. I have everything hooked up and it works reasonably well, but I'm having a heck of a time getting consistent behavior depending on how parameters are passed.

Is it possible to use the CursorAdapter to essentially provide only a Recordset to DBF conversion without letting the CA have anything to do in manipulating the SQL?

WHat I'm finding is that I can't add parameters to an ADO Command object directly and have the CA process the command. The CA always tries to step in and override the parameter behavior by doing VFP parameter parsing on it.

In most cases this is fine, but there aer a few instances when I need to explicitly override the parameter types to get the data into the database correctly. I also prefer the approach where users can add parameters explicitly using an AddParameter function which allows for all the type info.

So ideally I want to set up my own command object get it all set up and even create the Recordset on my own and then tell the CA to read the data from already retrieved Recordset. Or at least tell the CA to not do anything to the Command object at all but just call Execute to generate the RS.

Is this possible?
*** Set up or reuse adoConn object.
IF !THIS.Connect()
   this.nSqlResult = -1
   RETURN -1   
ENDIF

LOCAL oCommand as ADODB.Command
oCommand = CREATEOBJECT("AdoDb.Command")
oCommand.ActiveConnection=this.oadoconn 
oCommand.CommandType= 1 &&adCmdText
*!*   IF LOWER(lcSql) = "exec"
*!*        oCommand.CommandType=4 && adCmdStoredProc
*!*   ENDIF   

oCommand.CommandText = lcSQL

*** Parse the parameters from oParameters collection
*** OR parse VFP style parameters 
THIS.AssignCommandParameters(oCommand)

LOCAL oRS as Adodb.Recordset
oRS = CREATEOBJECT("adodb.RecordSet")
oRS.ActiveConnection = this.oadoconn 
oRS.CursorType= 0  && adOpenForwardOnly

*** THIS RETURNS WHAT I NEED - but I can't tell
*** the CA to load it 
* oRS = oCommand.Execute()
*****

ca.DataSource = oRS  && Now assign

LOCAL llError, llResult
llResult = ca.CursorFill(.F., .F., 0, oCommand)

*** Gives error result about missing parameters etc.

*** Parsed command string: 
*** Select  * from wws_invoice where invdate < ?
*** Error: Sql Parameter is missing
*** Works with ADO - oCommand.Parameters.Count = 1
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Next
Reply
Map
View

Click here to load this message in the networking platform