473,385 Members | 1,780 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How do you execute a SQL DTS???

Hello.

How do you execute an existing SQL DTS package from a command button on an
Access form. I am not going to use Access data pages, just a standard form.

Thanks.

Matthew Wells
MW****@FirstByte.net
Nov 13 '05 #1
2 4555
You can save a DTS package down to a VB6 file from the DTS wizard in Sql
Server 2000. Access alone does not have enough horse power to run the
DTS package code by itself. Your best bet would be to import the DTS
package module to a vb6 (or vb.net) project and compile that into an
exe. Then you can use the Shell function to invoke the exe you created.

Dim RetVal As Variant
RetVal = Shell("C:\someDir\MyDTSPkg.exe")

If you have several tables you need to add data to in sql server, say 4
tables (because I had such a project) you will have 4 different
packages. I turned each package into a class module so that I could use
an Interface construct (in vb.net - can't do this with a vb6 Interface
because this procdedure uses inheritance - maybe you could but won't
work as reliably from vb6) where I could loop through each package
class. Looks something like this:

Public Interface ifDTS 'I added this Interface declare RunDTS
'to the first class module
End Interface

Public Class clsDTS0 'first DTS package class
Implements ifDTS 'note: RunDTS is alias for runDTS0()
Public Sub runDTS0() Implements ifDTS.RunDTS
...dts code here
End Class

Public Class clsDTS1 '2nd DTS package class
Implements ifDTS 'note: RunDTS is alias for runDTS1()
Public Sub runDTS1() Implements ifDTS.RunDTS
...dts code here
End Class

Public Class clsDTS2 '3rd DTS package class
Implements ifDTS 'note: RunDTS is alias for runDTS2()
Public Sub runDTS2() Implements ifDTS.RunDTS
...dts code here
End Class
Then in the Main Form Class module call the interface like this:

Private Sub RunAllDTS()
Dim i As Integer
Dim dts(2) As ifDTS 'create array of DTS packages
'here is where you are using inheritanc
'I think
dts(0) = New clsDTS0 1st package class
dts(1) = New clsDTS1 '2nd package class
dts(2) = New clsDTS2 '3rd package class
For i = 0 To Ubound(dts)
dts(i).RunDTS 'here is where the RunDTS alias comes in
Next
...
End Sub

This may seem like a little overkill for 3 DTS packages, but I had to
call each package in my project several times because I was reading
several delimited textfiles into sql server for each DTS package. Note:
these were several very large textfiles like 27 megs per text file,
about 55 of them. DTS way faster than using ADO.Net Fill method
(although ADO.Net2 has a SqlBulkCopy Class in VS.Net2005 that does what
DTS does, but still in Beta). But for runnning DTS from Access, this is
how I would do it.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #2
The Interface declaration got messed up on my first post. Here is the
Interface declaration again, corrected

Public Interface ifDTS 'I added this Interface declare
Sub RunDTS 'to the first class module
End Interface

Here is the declaration again without the notes

Public Interface ifDTS
Sub RunDTS
End Interface

Sub RunDTS is the alias for the subs in all the Classes. These Subs
could all be named the same or have different names. When you add each
class to the Interface, you Implement the alias, RunDTS. You have to
say
-->Implements ifDTS<-- right underneath the class declaration and then
for the sub you will reference in the Interface you have to say

-->Public Sub x() Implements ifDTS.RunDTS<--

where RunDTS is the alias for Sub x()

Here is the sample again without comments:

Public Interface ifDTS
Sub RunDTS
End Interface

Public Class clsDTS0
Implements ifDTS

Public Sub runDTS0() Implements ifDTS.RunDTS
Dim ifDTS.RunDTS
...dts code here
End Class

Public Class clsDTS1
Implements ifDTS
Public Sub runDTS1() Implements ifDTS.RunDTS
...dts code here
End Class

Public Class clsDTS2
Implements ifDTS
Public Sub runDTS2() Implements ifDTS.RunDTS
...dts code here
End Class
Then in the Main Form Class module call the interface like this:

Private Sub RunAllDTS()
Dim i As Integer
Dim dts(2) As ifDTS

dts(0) = New clsDTS0 1st package class
dts(1) = New clsDTS1 '2nd package class
dts(2) = New clsDTS2 '3rd package class
For i = 0 To Ubound(dts)
dts(i).RunDTS
Next
...
End Sub

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tim Williams | last post by:
I'm trying to write a simple python program to access a MySQL database. I'm having a problem with using MySQLdb to get the results of a SQL command in a cursor. Sometimes the cursor.execute works,...
2
by: Matt | last post by:
I want to exexute stored procedure in ASP, but it has error "Microsoft VBScript compilation (0x800A0401) Expected end of statement" on line (1). The stored procedure "sp_emp" contain "select *...
7
by: William Gill | last post by:
I have been trying to pass parameters as indicated in the api. when I use: sql= 'select * from %s where cusid = %s ' % name,recID) Cursor.execute(sql) it works fine, but when I try : sql=...
9
by: PyPK | last post by:
Hi if I have a function called tmp=0 def execute(): tmp = tmp+1 return tmp also I have def func1(): execute() ....
5
by: Gustavo Randich | last post by:
Hello, I'm writing an automatic SQL parser and translator from Informix to DB2. Now I'm faced with one of the most difficult things to translate, the "foreach execute procedure" functionality...
2
by: Norman Fritag | last post by:
Hi there The below code executes some queries. As newbie I was wondering weather you are better of using connection execute or command execute to execute queries? I am asking as...
2
by: Dune | last post by:
I'm trying to execute an aspx page by calling Server.Execute. The aspx page I'm trying to execute is in a different web app from the aspx page containing the Server.Execute statement. A slightly...
8
by: johnlichtenstein | last post by:
I am using cx_Oracle and MySQLdb to pull a lot of data from some tables and I find that the cursor.execute method uses a lot of memory that never gets garbage collected. Using fetchmany instead of...
1
by: gglegrp112 | last post by:
Is it possible to send an array as a parameter for an execute method in dbapi2 module? I'm using adodbapi and try to perfrom the following SQL query: select * from item where storeid in ('01',...
9
by: RN1 | last post by:
When a server encounters the line Response.Redirect("abcd.asp") in a ASP script, the server tells the browser that it has to be redirected to another page (which is abcd.asp, in this case)....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.