question

DevdasAmin-0952 avatar image
0 Votes"
DevdasAmin-0952 asked DevdasAmin-0952 answered

OLE Object fails on 2nd run in VFP 9 only under Windows 7

The following code in VFP works well for 1st time. Repeat run causes the error "OLE Object may be corrupt".
The only solution is to quit VFP and run the code again, but only once.

oCR = CREATEOBJECT("CrystalRuntime.Application")
oRpt = oCR.OpenReport(FULLPATH('')+"SAMPLE.RPT")

oConn = CREATEOBJECT("ADODB.Connection")
oConn.ConnectionString = "Provider=vfpoledb;Data Source="+ FULLPATH('')+";Collating Sequence=general;"
oConn.Open

oRS = CREATEOBJECT('adodb.recordset')
oRS.Open("SELECT * FROM SWDAT.DBF", oConn)

oRpt.Database.SetDataSource(oRS) && Throws Error on 2nd run : OLE Object may be corrupt
oRpt.Database.Tables.Item(1).Parent.Verify()




not-supported
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.


Did you release these objects (probably using RELEASE in reverse order)?


0 Votes 0 ·

1 Answer

DevdasAmin-0952 avatar image
0 Votes"
DevdasAmin-0952 answered

I have used the following code to clear from memory, but it hasn't worked:

oRS.Close
oConn.Close
RELEASE oRS
RELEASE oConn
RELEASE oRpt
RELEASE oCR

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.