I have been trying to get VFP code to store and retrieve picture files via ADO and the SQLOLEDB.1 provider. My lack of success prompted me to try downloading the MDAC 2.6. After this I could not even open a connection. Rolling back the MDAC 2.6 update allowed me to open connections once again.
Does anyone have successful code to upload to an Image field? The following code gives the bizarre error message "Property VALUE not found" on the line "oTempRecSet.fields("PICTURE").value = oStream.Read".
odbcservername="SERVER"
odbcusername="username"
loginpass="password"
oConnection = CreateObject("adodb.connection")
oConnection.ConnectionString="PROVIDER=SQLOLEDB;SERVER="+trim(odbcservername)+";DATABASE=DDHELP;UID="+trim(odbcusername)+";PWD="+trim(loginpass)+";"
oConnection.Open()
elog=""
For Each Error In oConnection.Errors
elog=elog+Error.Description+transform(Error.Number)+chr(13)+chr(10)
Next Error
if ""<>elog
messagebox(elog)
endif
oStream = CreateObject("ADODB.Stream")
oStream.type = 1 && adtypebinary
oStream.Open()
oStream.LoadFromFile("c:\picture")
oTempRecSet = CreateObject("adodb.recordset")
oTempRecSet.ActiveConnection = oConnection
oTempRecSet.Open("SELECT CLIENT_KEY, PICTURE FROM CLIENTS WHERE LNAME = 'Crandall '", , 1, 3)
oTempRecSet.fields("PICTURE").value = oStream.Read
oTempRecSet.Update
elog=""
For Each Error In oTempRecSet.Errors
elog=elog+Error.Description+transform(Error.Number)+chr(13)+chr(10)
Next Error
if ""<>elog
messagebox(elog)
endif
oConnection.Close()
oConnection = ""
Randy Hersom
President, Habilitation Software Inc.