Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
CursorAdapter Bug Repro Code...
Message
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
CursorAdapter Bug Repro Code...
Divers
Thread ID:
00762796
Message ID:
00762796
Vues:
52
...or maybe not a bug, but it is darned puzzling. The database is Northwind in MSDE/SQL Server. The DataSourceType is ADO. The code runs 2 slightly different SelectCMD properties. One returns data the other does not. Yet why one does not is totally baffling. The 2 select SQL are:
SELECT * FROM Customers WHERE CustomerID LIKE ?cCustomerID ;
   ORDER BY CompanyName
SELECT * FROM Customers WHERE CompanyName LIKE ?cCompany ;
   ORDER BY CompanyName
The first one returns no data. If you create an ODBC connection to the same database and use SPT, the first SQL does return data. The following code will reproduce these results. You may need to modify the ADO Connection String to connect to your Northwind database in MSDE or SQL Server.

The property lSelectID controls which SelectCmd is used and the order of use of the SelectCmd SQL does not matter. lSelectID can be first .T. then .F. or it can be .F. then .T. You get the same results either way.

Any clues most appreciated.
*!* ADO CursorAdapter Example for the
*!* SQL Server Northwind sample database
*!*
LOCAL oXC

oXC = CREATEOBJECT('xcADO')
oXC.lSelectID = .T.
oXC.GetSQLData()
CLEAR
IF oXC.lFilled
   LIST STRUCTURE
   BROWSE LAST NORMAL TITLE oXC.SelectCmd
ELSE
   MESSAGEBOX('CursorFill Failed')
   ?
   ? 'CursorFill Failed'
   ? oXC.aErrorInfo(1)
   ? oXC.aErrorInfo(2)
ENDIF
oXC.lSelectID = .F.
oXC.GetSQLData()
IF oXC.lFilled
   CLEAR
   LIST STRUCTURE
   BROWSE LAST NORMAL TITLE oXC.SelectCmd
ELSE
   MESSAGEBOX('CursorFill Failed')
   ?
   ? 'CursorFill Failed'
   ? oXC.aErrorInfo(1)
   ? oXC.aErrorInfo(2)
ENDIF
oXC.RELEASE()
RETURN


DEFINE CLASS xcADO AS CURSORADAPTER

   lSelectID = .F.
   cCompanyName = [M%]
   cCustomerID = [M%]

   ALIAS = [crsCustomers]
   DATASOURCETYPE = [ADO]

   lFilled = .F.
   nError = 0
   DIMENSION aErrorInfo(1)

   PROTECTED PROCEDURE INIT
      CLEAR
      THIS.ADDPROPERTY('oConn', NEWOBJECT('ADODB.Connection'))
      THIS.ADDPROPERTY('oRS', NEWOBJECT('ADODB.Recordset'))
      THIS.ADDPROPERTY('oCommand', NEWOBJECT('ADODB.Command'))

      WITH THIS.oConn
         .CursorLocation = 3
         .ConnectionString = ;
              [Provider=SQLOLEDB.1;Integrated Security=SSPI;] ;
            + [Persist Security Info=False;] ;
            + [Initial Catalog=Northwind;Data Source=localhost]
         .OPEN()
      ENDWITH
      THIS.oCommand.ActiveConnection = THIS.oConn
      WITH THIS.oRS
         .ActiveConnection = THIS.oConn
         .CursorType       = 1  && adOpenKeyset
         .CursorLocation   = 3  && adUseClient
         .LockType         = 3  && adLockOptimistic
      ENDWITH
      THIS.DATASOURCE = THIS.oRS
   ENDPROC
   PROCEDURE GetSQLData
      IF THIS.lSelectID
         THIS.SelectCmd = [SELECT * FROM Customers WHERE ] ;
           + [CustomerID LIKE ?cCustomerID ORDER BY CompanyName]
      ELSE
         THIS.SelectCmd = [SELECT * FROM Customers WHERE ] ;
           + [CompanyName LIKE ?cCompany ORDER BY CompanyName]
      ENDIF
      THIS.ResetError()
      LOCAL cCompany, cCustomerID
      cCompany = THIS.cCompanyName
      cCustomerID = THIS.cCustomerID
      THIS.lFilled = THIS.CURSORFILL(.F., .F., -1, THIS.oCommand)
      IF NOT THIS.lFilled
         THIS.nError = AERROR(THIS.aErrorInfo)
      ENDIF
   ENDPROC
   PROTECTED PROCEDURE ResetError
      THIS.nError = 0
      THIS.aErrorInfo = []
   ENDPROC
   PROTECTED PROCEDURE DESTROY
      THIS.oRS = .NULL.
      THIS.oConn = .NULL.
      THIS.oCommand = .NULL.
   ENDPROC
   PROCEDURE RELEASE
      RELEASE THIS
   ENDPROC
ENDDEFINE
Mark McCasland
Midlothian, TX USA
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform