Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ADO - Find field ordinal
Message
De
27/06/2001 05:10:07
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
27/06/2001 03:12:32
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Divers
Thread ID:
00523996
Message ID:
00524013
Vues:
15
>HI!
>
>I was reading that accessing a field object by ordinal is 400 % faster..
>
>For example:
>
>oRS.fields("name").value
>vs
>oRS.fields(0).value
>
>Well I can't really use this I have an idea.
>I'll save the ordinal value in a class property after the first look up.
>So that at least refreshes are faster in code like..
>
>this.value=oRS.fields(this.name).value
>
>The question is if I have a fields object how do I get the ordinal.
>I checked all the properties and couldn't find a way to do it...
>Except...
>FOR i=0 to oRS.fields.count
> IF oRS.fields.name="name"
> ?i
> END
>ENDFOR
>Which can't be faster...
>
>So If I'm unclear. I am looking for a way to return the ordinal position of a field object knowing it's name..
>oRS.fields("name").value=oRS.fields(n).value
>How can I find n when I know "name"?
>
>Thanks

Tim,
Do a one pass to collect names to an array - say thisform.arrFields.
dimension thisform.arrFields[oRS.Fields.Count]
FOR i=0 to oRS.fields.count-1
    thisform.arrFields[i+1] = oRS.fields.name
ENDFOR

oRS.Fields(ascan(thisform.arrFields,lcFields)-1).Value
Or just collect the names to a string separated with commas (no spaces between fieldname and comma):
lnOrdinal = occurs(',',left(lcFieldList,atc(','+lcField+',',lcFieldList))
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform