Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CursorAdapter duplicates record
Message
From
14/09/2009 15:40:06
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
CursorAdapter duplicates record
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01424271
Message ID:
01424271
Views:
93
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()
Next
Reply
Map
View

Click here to load this message in the networking platform