>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
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement