Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Crystal Reports - Passing Parameters to
Message
De
02/05/2005 14:34:24
 
 
À
02/05/2005 14:28:47
Andy Roth
Neyenesch Printers
Californie, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Crystal Reports
Divers
Thread ID:
01010203
Message ID:
01010260
Vues:
27
Here's an example on how to login to the SQL database. It doesn't matter if the app is already logged in, the report object needs to set every table used in the report to the correct SQL login info. Any questions on this, let me know.
PROCEDURE LogOnSQL
This.FixUpTables()
* look for subreports, update SQL Server logon info
		FOR EACH loSection IN This.oReport.Sections
			WITH loSection
				FOR EACH loReportObject IN .ReportObjects
					IF loReportObject.Kind = crSubreportObject
						loSubreport = This.oReport.OpenSubreport(loReportObject.SubreportName)

						WITH loSubreport
							STORE .F. TO .MorePrintEngineErrorMessages, .EnableParameterPrompting
						ENDWITH

						This.FixUpTables(loSubreport, lcSQLServer, lcDBName, lcUserID, lcPswd)

						loSubreport = .null.
					ENDIF
				NEXT loReportObject
				loReportObjects = .null.
			ENDWITH
		NEXT loSection
ENDPROC

******************************************	
	PROCEDURE FixUpTables
	******************************************		

		LPARAMETER toReport, tcSQLServer, tcDBName, tcUserID, tcPswd

		LOCAL loTable, lcLocation, lcUserID, lcPswd, sConnString

		FOR EACH loTable IN toReport.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
		
		loTable = .null.
ENDPROC
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform