[V4RB2] Field.value speed

Kem Tekinay ktekinay at mactechnologies.com
Tue Mar 29 15:38:15 CST 2005


On 3/29/05 1:07 PM, Frank Schima at macsforever2000 at goodeast.com wrote:

> Can you post your code for getting information out of a VCursor
> including the code that creates the cursor? Maybe the answer lies
> there.

Sure. Here is the code that creates the cursor:

  dim find, sql as string
  dim curs as VCursor
  dim startTicks, endTicks as integer
  dim b as boolean
  
  find = lowercase( fldSearch.Text )
  
  if find = "" then
    sql = "SELECT * FROM Zip_Codes"
  else
    sql = "SELECT * FROM Zip_Codes WHERE " + _
        "Zip_Code LIKE '" + find + "%' " + _
        "OR lower(City) LIKE '" + find + "%' " + _
        "OR lower(State) LIKE '" + find +"%'"
  end if
  
  startTicks = ticks
  
  b = gDB.TblZipCodes.Zip_Code.FindStartsWith( find )
  try
    curs = gDB.SQLSelect( sql, EVCursorLocation.kClientSide,
EVLockType.kReadOnly, EVCursorDirection.kForwardOnly )
  catch err as VException
    MsgBox gDB.ErrString
  end try
  
  endTicks = ticks
  
  if curs <> nil then
    zRecSet = nil
    zRecSet = curs
    curs = nil
    fldRecordCount.Text = format( self.zRecSet.RecordCount, "#," )
    lbZips.Reset( self.zRecSet.RecordCount )
    fldSearchTicks.Text = format( endTicks - startTicks, "#,0" ) + " ticks"
  else
    fldSearchTicks.Text = ""
  end if
  
Here is the code that reads information from the cursor:

  zRecSet.Position = dataRow + 1
  
  if column < 3 then
    result = zSortField.Value
  else
    result = format( zSortField.Value.DoubleValue + 1000 , "000,000.000" )
// Compensate for negative numbers
  end if
  
  result = result + " " + str( dataRow ) // Keep it unique

The variable dataRow represents a 0-based index for the record. The variable
zSortField is set as follows:

  zSortField = zRecSet.Field( me.Heading( column ) )


__________________________________________________________________________
Kem Tekinay                                                 (212) 201-1465
MacTechnologies Consulting                              Fax (914) 242-7294
545 Eighth Avenue, Suite 401                          Pager (917) 491-5546
New York, New York 10018                    http://www.mactechnologies.com

To join the MacTechnologies Consulting mailing list, send an e-mail to:
  mactechnologies_consulting-subscribe at yahoogroups.com





More information about the Valentina mailing list