Information générale
Catégorie:
Codage, syntaxe et commandes
Titre:
ADO and VFP6 (updated with SP5)
Anyone able to help?
I have VFP6 (SP5). I am trying to use ADO programmatically. The connection that I have created works fine. I have managed to connect. However, I am having problems using the Recordset object; i.e., passing the data to object on a form.
I seem to think it is impossible to use the USE IN statement. If this is not so, how do I?
The code I have used is as follows:
&&local variables
Local oConnection, lcConnectionString, oRecordSet, lsSavedRecordSetLocation
&&create the ADO objects
&&--------------------------------
oConnection = Createobject("adodb.connection")
oRecordSet = CreateObject("adodb.recordset")
&&connection details
&&-------------------------
oConnection.CursorLocation = adUseClient
lcConnectionString = "Provider=MSDASQL.1;" +
"Password=scotland;" +
"Persist Security Info=True;" +
"User ID=sue;" +
"Data Source=SQLHomeInfo;" +
"Mode=ReadWrite;" +
"Initial Catalog=HomeInfo"
oConnection.Open = lcConnectionString
&&recordset settings
&&-----------------------
With oRecordSet
.LockType = adLockbatch
.CursorType = adopenstatic
.ActiveConnection = oConnection
.Open('Select * from stock')
.ActiveConnection = Null
Endwith
*lsSavedRecordSetLocation = (HOME(2) + 'data/shopper.rs')
*oRecordSet.Save("c:\data manager\data\shopper.rs")
*WAIT WINDOW "Data stored to the hard drive" + CHR(13) + "" + CHR(13) && WAIT
*release oconn
*0RecordSet.Open("c:\data manager\data\shopper.rs",,3,3)
*if not(err) then &&ADO is not installed
*WAIT WINDOW "ADO is installed" + CHR(13) + "" + CHR(13) && WAIT
*endif
&&putting the data into object on a form
&&---------------------------------
RemoteShopper.My_shopper_editor1.my_pcode1.controlsource = oRecordSet.Fields("pcode").value
** more fields filled with data - code left out **
frmMyForm.SHOW && Display the form
Read EVENTS && Start event processing
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