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:
01058696
Views:
28
>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?
>

You will either have to do it via a script task within DTS, or (better yet) use SQL-DMO to do it. DMO has a rich object model that you can use within VFP very easily. Here is a sample that I created that constructs an entire SQL database from scratch:
LOCAL oDb as SQLDMO.Database, oSvr as SQLDMO.sqlserver,;
oIndex as SQLDMO.index

* create a database
oDb = NEWOBJECT('sqldmo.database')
oDb.Name = 'testnumber2'

* create a database file
oDbFile = NEWOBJECT('sqldmo.dbfile')
oDbFile.Name = 'testnumber1'
oDbFile.PhysicalName = 'c:\sqldata\testnumber2.mdb'
oDbFile.Size = 10

* add the file to the DB file group
oDb.FileGroups('primary').DBFiles.Add(oDbFile)

* create a server object and add the new DB to it
oSvr = NEWOBJECT('sqldmo.sqlserver')
oSvr.LoginSecure = .t.
oSvr.Connect('(local)')
oSvr.Databases.Add(oDb)

* create a table
oTable1 = NEWOBJECT('sqldmo.table')
oTable1.Name = 'tbl_parent'

* add columns to the table
oCol1 = NEWOBJECT('sqldmo.column')
oCol1.Name = 'crandomname'
oCol1.Datatype = 'char'
oCol1.Length = 10
oTable1.Columns.Add(oCol1)

* add the table to the database
oDb.Tables.Add(oTable1)

* cannot reuse the table object unless you release it
* so we'll create a new one
oTable2 = NEWOBJECT('sqldmo.table')
oTable2.Name = 'tbl_child'
oCol1 = NEWOBJECT('sqldmo.column')
oCol1.Name = 'crandomname'
oCol1.Datatype = 'char'
oCol1.Length = 10
oTable2.Columns.Add(oCol1)

* add the table to the database
oDb.Tables.Add(oTable2)

* create an index
oIndex = NEWOBJECT('sqldmo.index')
oIndex.Name = "cRandomName"
oIndex.IndexedColumns = "crandomname"
oTable1.Indexes.Add(oIndex)
DMO is covered extensively in the BOL, check it out.
Dan LeClair
www.cyberwombat.com
SET RANT ON - The Wombat Blog

Life isn’t a morality contest and purity makes a poor shield. - J. Peter Mulhern
Disclaimer: The comments made here are only my OPINIONS on various aspects of VFP, SQL Server, VS.NET, systems development, or life in general, and my OPINIONS should not be construed to be the authoritative word on any subject. No warranties or degrees of veracity are expressed or implied. Void where prohibited. Side effects may included dizziness, spontaneous combustion, or unexplainable cravings for dark beer. Wash with like colors only, serve immediately for best flavor.
Previous
Reply
Map
View

Click here to load this message in the networking platform