Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DTS Packages from FoxPro, How?
Message
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
01056960
Message ID:
01057222
Views:
29
Thanks much Kurt, that gave me some ideas where to start, something else, with the code you gave me I could read and set some of the properties I want to control but could not find a way to add or remove objects, (read tables here), have you done it before or is something not doable?

Thanks much

>Luis,
>
>Not certain what you mean by 'control' a dts package. Here's a program I wrote to change the AS400 database names within SQL DTS packages. It finds all dts packages that match a certain filter criteria and then changes the DBName from our production name to test name (or vice versa). Hopefully it will give you a clue as to how to modify DTS packages via foxpro. Note : You must have the SQL Client tools install on the pc in order to access the DTS.Package object.
>
>
>********************************************************************************
>* Method		: Dtsmodify.Prg()
>* Author		: Kurt Huebner
>* Copyright		: (c) 2003 Blue Diamond Growers
>* Date			: 8/7/2003 3:01:54 PM
>* Parameter(s)	: <none>
>* Modified		: 1. mm/dd/yyyy -
>* Notes			: This procedure is used to modify all of the DTS packages. It
>*				: changes the source database from test to production (or vice versa)
>*				: Two variables need to be set when running this program:
>*				:	lcFilter = Which DTS Pkgs to change
>*				:   lcDBName = Name of the AS/400 database to change the select
>*				:	statement to.
>********************************************************************************
>LOCAL 	loDtspkg	AS 'DTS.Package2',;
>		loConn		AS 'ADODB.Connection',;
>		loRecordSet	AS 'ADODB.RecordSet',;
>		loCommand	AS 'ADODB.Command',;
>		lcDtsName	AS String,;
>		lcFilter	AS String,;
>		lcDBName	AS String,;
>		lcOldDbName	AS String
>
>#INCLUDE C:\GIS7\LIBS\adovfp.h
>CLEAR
>RETURN
>*	Set the filter for which DTS packages to change		
>lcFilter = 'Import%'
>lcDBName = 'GISSPRDDTA'
>
>
>*	Determine the old DB name to search for in the DTS package
>lcOldDbName = IIF(lcDbName = 'GISSPRDDTA','GISSSYSTST','GISSPRDDTA')
>
>*	Read the names of all DTS packages
>loConn	= CREATEOBJECT('ADODB.Connection')
>loConn.Open('Provider=SQLOLEDB.1;Password="XXXX";User ID=XXXXX;Initial Catalog=bdggis;Data Source=BDGGIS')
>
>loRecordSet 					= CREATEOBJECT('ADODB.RecordSet')
>loRecordSet.CursorType 			= ADOPENDYNAMIC 	
>loRecordSet.LockType 			= ADLOCKOPTIMISTIC
>loRecordSet.ActiveConnection 	= loConn
>loRecordSet.CursorLocation 		= ADUSECLIENT
>
>loCommand 						= CREATEOBJECT('ADODB.Command')
>loCommand.ActiveConnection 		= loConn
>loCommand.CommandText 			= 'SELECT DISTINCT t0.name FROM msdb.dbo.sysdtspackages t0 WHERE t0.name LIKE ?'
>loCommand.Parameters(0).Value 	= lcFilter
>
>loRecordSet.Open(loCommand)
>
>loRecordSet.MoveFirst()
>DO WHILE NOT loRecordSet.EOF()
>	*	Get the name of the DTS package
>	lcDtsName = loRecordSet.Fields('name').Value
>	
>	loDtsPkg = CREATEOBJECT('DTS.Package2')
>	loDtsPkg.LoadFromSQLServer('BDGGIS','dtspkg','dtspkg',,,,,lcDtsName)
>
>	FOR EACH loTask IN loDtsPkg.Tasks
>		FOR EACH loProperty IN loTask.Properties
>			IF loProperty.Name = 'SourceSQLStatement'
>				lcSourceSqlStatement = loProperty.Value
>				lcNewSqlStatement = STRTRAN(lcSourceSqlStatement,lcOldDbName, lcDBName)
>				
>				IF lcSourceSqlStatement <> lcNewSqlStatement
>					loProperty.Value = lcNewSqlStatement
>					loDtsPkg.SaveToSQLServer('BDGGIS','dtspkg','dtspkg')
>					? 'Updated '+lcDtsName
>					EXIT
>				ENDIF					
>			ENDIF
>		ENDFOR
>	ENDFOR
>
>	loRecordSet.MoveNext()
>ENDDO
>
>
>Hope this helps,
>Kurt
>
>>Hello everyone!,
>> I need to know how to control a SQL Server DTS package from within Fox,
>>I have seen the examples in visual basic, but can't figure out how to translate that into fox, it looks that VB comes with a DTS object built in which makes it easier, am I right?, can somebody guide me here?
>>
>> THIS.Thanx("In Advance")
Luis Guzman, MCP
"The only glory most of us have to hope for
is the glory of being normal." Katherine Fulleton Gerould
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform