I try to find out how to pass an ADO record from a free VFP-table to CR.
My code looks like:
LOCAL oCR AS CRAXDRT.Application
LOCAL oRpt AS CRAXDRT.Report
LOCAL oDB AS CRAXDRT.Database
LOCAL ocDBT AS CRAXDRT.DatabaseTables
LOCAL oDBT AS CRAXDRT.DatabaseTable
LOCAL ocParm AS CRAXDRT.ParameterFieldDefinitions
LOCAL oParm AS CRAXDRT.ParameterFieldDefinition
LOCAL oConn AS ADODB.Connection
LOCAL oRS AS ADODB.Recordset
* Handle the ADO stuff
lcSource="F:\SHARED\DEVELOPMENT\FOX\WPLUMBER\TEMP\CHUDO1.DBF"
oConnection=CREATEOBJECT('ADODB.Connection')
oConnection.ConnectionString = "Provider=VFPOLEDB.1;Data Source="+lcSource+";Password=''"
lnAffected=0
lcSQL="SELECT * FROM FROM CHUDO1"
oConnection.Open()
IF oConnection.State = 1 && connected sucessfully
oConnection.Execute(lcSQL,@lnAffected)
IF lnAffected > 0
MESSAGEBOX("ok")
ELSE
MESSAGEBOX("not ok")
ENDIF
ELSE
MESSAGEBOX("no connection")
ENDIF
The first error is on the line "oConnection.Execute(lcSQL,@lnAffected)"
The program can not execute the sql expression
Question: there is no db, why to I have to use ADODB.Connection?
I have a procedure without ADODB that works and looks like:
parameter LlparFileName
LOCAL oCR AS CRAXDRT.Application
LOCAL oRpt AS CRAXDRT.Report
LOCAL oDB AS CRAXDRT.Database
LOCAL ocDBT AS CRAXDRT.DatabaseTables
LOCAL oDBT AS CRAXDRT.DatabaseTable
oCR = CREATEOBJECT("CrystalRuntime.Application")
oRpt = CREATEOBJECT("CrystalRuntime.Report")
oRpt = oCR.OpenReport(".\reports\report.rpt")
* Create the Database object
oDB = oRpt.Database()
* Get a references to the DatabaseTables collection
ocDBT = oDB.Tables()
oDBT = ocDBT.Item(1)
oDBT.connectbufferstring=""
*lcPath=".\temp"
lcPath=SYS(2023)
oDBT.connectbufferstring="Provider=VFPOLEDB;;Data Source="+lcPath+";;User ID=;;Password=;;Locale Identifier=1033;;OLE DB Services=-5;;Collating Sequence=Machine;;DSN="
oDBT.Location = LlparFileName
......
what is the difference?
Tia
Ron
My code looks like:
LOCAL oCR AS CRAXDRT.Application
LOCAL oRpt AS CRAXDRT.Report
LOCAL oDB AS CRAXDRT.Database
LOCAL ocDBT AS CRAXDRT.DatabaseTables
LOCAL oDBT AS CRAXDRT.DatabaseTable
LOCAL ocParm AS CRAXDRT.ParameterFieldDefinitions
LOCAL oParm AS CRAXDRT.ParameterFieldDefinition
LOCAL oConn AS ADODB.Connection
LOCAL oRS AS ADODB.Recordset
* Handle the ADO stuff
lcSource="F:\SHARED\DEVELOPMENT\FOX\WPLUMBER\TEMP\CHUDO1.DBF"
oConnection=CREATEOBJECT('ADODB.Connection')
oConnection.ConnectionString = "Provider=VFPOLEDB.1;Data Source="+lcSource+";Password=''"
lnAffected=0
lcSQL="SELECT * FROM FROM CHUDO1"
oConnection.Open()
IF oConnection.State = 1 && connected sucessfully
oConnection.Execute(lcSQL,@lnAffected)
IF lnAffected > 0
MESSAGEBOX("ok")
ELSE
MESSAGEBOX("not ok")
ENDIF
ELSE
MESSAGEBOX("no connection")
ENDIF
The first error is on the line "oConnection.Execute(lcSQL,@lnAffected)"
The program can not execute the sql expression
Question: there is no db, why to I have to use ADODB.Connection?
I have a procedure without ADODB that works and looks like:
parameter LlparFileName
LOCAL oCR AS CRAXDRT.Application
LOCAL oRpt AS CRAXDRT.Report
LOCAL oDB AS CRAXDRT.Database
LOCAL ocDBT AS CRAXDRT.DatabaseTables
LOCAL oDBT AS CRAXDRT.DatabaseTable
oCR = CREATEOBJECT("CrystalRuntime.Application")
oRpt = CREATEOBJECT("CrystalRuntime.Report")
oRpt = oCR.OpenReport(".\reports\report.rpt")
* Create the Database object
oDB = oRpt.Database()
* Get a references to the DatabaseTables collection
ocDBT = oDB.Tables()
oDBT = ocDBT.Item(1)
oDBT.connectbufferstring=""
*lcPath=".\temp"
lcPath=SYS(2023)
oDBT.connectbufferstring="Provider=VFPOLEDB;;Data Source="+lcPath+";;User ID=;;Password=;;Locale Identifier=1033;;OLE DB Services=-5;;Collating Sequence=Machine;;DSN="
oDBT.Location = LlparFileName
......
what is the difference?
Tia
Ron