Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Running an OLEDB Report
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Crystal Reports
Versions des environnements
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01023991
Message ID:
01025220
Vues:
23
This message has been marked as the solution to the initial question of the thread.
Heres the Code that Finally Worked for this...
PARAMETERS tcReportname, tcSQLServer, tcDBName, tcUserID, tcPswd

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 oConn AS ADODB.CONNECTION
LOCAL oRS AS ADODB.Recordset

DO CASE
	CASE PCOUNT() = 0
		* Handle the ADO 
		tcSQLServer = 'SQLSERVER'
		tcDBName	= 'Reporting_Data'
		tcUserID	= 'report'
		tcPswd		= 'report'
		tcReportname= 'conditional_approvals_oledb.rpt'
ENDCASE


cFileName = tcReportname


cConnString = "User ID=" + ALLTRIM(tcUserID) + ";"
cConnString = cConnString + "Password=" + ALLTRIM(tcPswd) + ";"
cConnString = cConnString + "Initital Catalog=" + ALLTRIM(tcDBName) + ";"
cConnString = cConnString + "Data Source=" + ALLTRIM(tcSQLServer)

oConn = CREATEOBJECT("ADODB.Connection")
oConn.Provider = "SQLOLEDB.1"
oConn.ConnectionString = cConnString
oConn.OPEN()

oRS = CREATEOBJECT("ADODB.RecordSet")

oCR = CREATEOBJECT("CrystalRuntime.Application.9")
oRpt = oCR.OpenReport(cFileName)

* Create the Database object
oDB = oRpt.DATABASE()

* Get a references to the DatabaseTables collection
ocDBT = oDB.TABLES()

FOR EACH loTable IN oRpt.DATABASE.TABLES
	WITH loTable
		lcLocation = .Location
		*** connect to SQL Server using OLEDB (ConnectionProperties)
		loConnProps = loTable.ConnectionProperties
		*** delete all existing connection properties
		loConnProps.DeleteAll()
		*** add new connection properties
		loConnProps.ADD("Provider","SQLOLEDB")

		loConnProps.ADD("Data Source",tcSQLServer)
		loConnProps.ADD("Initial Catalog",tcDBName)

		loConnProps.ADD("User ID",tcUserID)

		** check for dbl quote - change to chr(34)
		** tcPswd = ScrubDblQuote(tcPswd)

		loConnProps.ADD("Password", tcPswd)
		IF "Proc(" $ lcLocation
			lcLocation = STRTRAN(lcLocation,"Proc(","")
			lcLocation = STRTRAN(lcLocation,")","")
		ENDIF
		.Location = tcDBName + ".dbo." + lcLocation

	ENDWITH
NEXT loTable

* Get a reference to the DatabaseTable object for table 1
oDBT = ocDBT.ITEM(1)

IF oRpt.HasSavedData
	oRpt.DiscardSavedData()
ENDIF

* Set the export options
loExportOptions = oRpt.ExportOptions
loExportOptions.DestinationType = 1 	&& crEDTDiskFile

loExportOptions.FormatType = 31
loExportOptions.DiskFileName 	= "C:\Export.PDF"
** oRpt.DiscardSavedData()

oRpt.ReadRecords
oRpt.EXPORT(.F.)
Thanks for Everyones Help!!

>Hi Craig,
>
>The Part that I am trying to do away with on Page 218 is the
>oCommand.CommandText = "Select * from Customers where Country = 'France'"
>That is the part(s) that are defined in the Crystal Report...
>
>I just want to take a OLEDB Crystal Report, Pass the Login Credentials
>and run it...
>
>So in ODBC I just cruise through the Tables and do a quick little:
>
>oDBT = ocDBT.ITEM(1)
>
>FOR jnx = 1 TO ocDBT.COUNT
> oDBT.SetLogOnInfo("Acaps_Reports",'report','report')
>ENDFOR
>
>But in OleDb it doesnt seem I can do this... ??
>
>Thanks!
>Bob
>
>
>
>
>>Look at the example on page 218 in my book.
>>
>>Essentially, there is no difference to Crystal when connecting via ODBC or OLE DB/ADO.
>>
>>Are you getting error messages?
>>
>>
>>>Hi Craig,
>>>
>>>Thank you for the samples and I the Book you wrote is awesome as well...
>>>
>>>The samples on the web site / book show that I have to
>>>Create a Recordset and then Pass it...
>>>
>>>But all this information is in the .RPT Report...
>>>Do I have to do this all 2X??
>>>
>>>Thanks!
>>>Bob
>>>
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform