Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
CursorAdapter duplicates record
Message
De
14/09/2009 15:40:06
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
CursorAdapter duplicates record
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01424271
Message ID:
01424271
Vues:
92
Hi,

I am getting duplicated records when fill CursorAdapter - see the example
Local loConn as "ADODB.Connection", loCmd as "ADODB.Command", loCursorAdapter as CursorAdapter
Local loParameter0 as "ADODB.Parameter", loParameter1 as "ADODB.Parameter", loRs as ADODB.Recordset
* create and oppen ADODB.Connection
loConn = NewObject("ADODB.Connection")
loConn.ConnectionString = "Provider=VFPOLEDB.1;Data Source='Base\Scd4.dbc';Password='';Collating Sequence=MACHINE"
loConn.Open()
* create and configure ADODB.Command
loCmd = NewObject("ADODB.Command")
loCmd.ActiveConnection = loConn
loCmd.CommandText = "Select * from Distr where (dis_data >= ? and dis_data <= ?)"
* create parameters and add it to ADODB.Command
loParameter0 = loCmd.CreateParameter("pDateIni", 133, 1, 8, this.txtDateIni.Value)
loParameter1 = loCmd.CreateParameter("pDateFin", 133, 1, 8, this.txtDateFin.Value)
loCmd.Parameters.Append(loParameter0)
loCmd.Parameters.Append(loParameter1)
* create and fill ADODB.RecordSet
loRs = NewObject("ADODB.RecordSet")
loRs.Open(loCmd, , 1) && loRs.CursorType = 1  && adOpenKeyset see "RecordSet types" in http://msdn2.microsoft.com/en-us/library/ms917355.aspx

* check the RecordCount
?loRs.RecordCount && ------------------------------------ DISPLAY 355 - CORRECT RESULT

* transfer data to CursorAdapter to display in a grid
loCursorAdapter                    = NewObject("CursorAdapter")
loCursorAdapter.Alias              = "curResult"
loCursorAdapter.DataSourceType     = "ADO"
loCursorAdapter.CursorFill(.F., .F., 0, loRs)

? Reccount("curResult") && ------------------------------ DISPLAY 455 - INCORRECT RESULT - have 100 records duplicated in CA

* close ADODB.Connection
loConn.Close()
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform