Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VFP best front end?
Message
 
À
18/03/1998 16:07:35
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Divers
Thread ID:
00084741
Message ID:
00085471
Vues:
39
>It makes sense that ADO could be used with VFP5, but it would really be helpful if you could EMail me an example? I would greatly appreciate it!


Hi John,

Here is some code that accepts a member id and validates it against a table. This is a good example as all 4 ADO Objects are used.

Whats really cool here is the parameter object. You can specify parameters - their data types an length ahead of time. Bascially, there is no way to pass bad parameters. Otherwise, you will get OLE Errors. This beats manually rebuilding your SQL string each time you need to run a query.

Let me know if you have any ?'s...



Procedure IsAValidMember(memberid)
#Define adChar 129
#Define adparamInput 1
#Define True .T.
#Define False .F.

Local oConnection,oRecordset,oCommand,oParameter,retval

retval = False

oConnection = CreateObject("adodb.connection")
oRecordSet = CreateObject("adodb.recordset")
oCommand = CreateObject("adodb.command")
oParameter = CreateObject("adodb.parameter")

oConnection.Open("aaamidatlantic")
oCommand.activeconnection = oConnection
oCommand.commandtext = "Select * From Member Where hh_id = ?"
oParameter = oCommand.CreateParameter("hh_id",adChar,adParamInput,Len(memberid),memberid)
ocommand.parameters.append(oparameter)
oRecordSet = ocommand.execute()

retval = Not oRecordSet.Eof
oRecordSet.Close
oConnection.Close

Release oConnection,oRecordset,oCommand,oParameter

Return retval

endProc
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform