Showing posts with label activex. Show all posts
Showing posts with label activex. Show all posts

Tuesday, March 27, 2012

Calling Stored Procedure from an ActiveX task

I'm attempting to call a storedprocedure from within an ActiveX task in
a DTS and am getting a "Command Text was not set for the command
object" error. I have no problem if I replace the stored procedure call
with the actual SQL.

Is it possible to directly call a SP via an ActiveX task? If yes, could
somebody help me with the syntax please?

This is what I have currently have

Set Conn = CreateObject("ADODB.Connection")
SQL = "exec (MySP)"
set RLoop=conn.Execute(SQL)

do while (NOT RLoop.EOF)
msgbox RLoop(1)
RLoop.MoveNext

Loop

TIA

KarthikKarthik (karthiksmiles@.gmail.com) writes:
> I'm attempting to call a storedprocedure from within an ActiveX task in
> a DTS and am getting a "Command Text was not set for the command
> object" error. I have no problem if I replace the stored procedure call
> with the actual SQL.
> Is it possible to directly call a SP via an ActiveX task? If yes, could
> somebody help me with the syntax please?
> This is what I have currently have
> Set Conn = CreateObject("ADODB.Connection")
> SQL = "exec (MySP)"
> set RLoop=conn.Execute(SQL)

Cmd = CreateObject("ADODB.Command")
Cmd.ActiveConnection = Conn
Cmd.CommandType = adStoredProcedure
Cmd.CommandText = "MySP"
Set rs = cmd.Execute

Not that I have ever done it in DTS, but this should be like ADO anywhere
else.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx

Calling Stored proc in ActiveX script

Hi!
How do you call a store procedure in an ActiveX script? I have a stored procedure that I want to execute everytime my Data Driven Query tasks inserts a new record.
Thanks.Dim oConn
Dim oComm

Set oConn = CreateObject("ADODB.Connection")
Set oComm = CreateObject("ADODB.Command")

oConn.ConnectionString = sConnectionString
oConn.Open

oComm.CommandText = "myStoredProc"
oComm.CommandType = 4 ' adStoredProc
oComm.Parameters.Refresh
oComm.Parameters("myParam") = "This"
oComm.ActiveConnection = oConn

oComm.Execute

(alternatively)

Set oRS = oComm.Execute

Written from the top of my head. Your mileage may very. Check syntax carefully. Never run while carrying scissors by the handle. Always keep your barrel pointed downrange.

Regards,

hmscott|||thanks for the advice!

Tuesday, March 20, 2012

Calling DTS from C#

Hi all,

i have a DTS package that i call from a C# app, i had it working great until i decided to use an activeX script to do the data transformations instead of the row copy.

I need to use ActiveX to add a standard name to the last column in the destination table. the problem is the task is executing without errors (from c#) but nothing is happening, its failing silently. If i modify the Data Transformation back to a standard column mapping (with separate DTSTransformations for each column) it works fine, but as soon as i use activeX to handle the transformations it doesn't work.

Can anyone tell me what i may be doing wrong.

heres the calling code from C#

if(f.Name.Substring(13,7).ToLower() =="product"){try{activity.Log("Starting Product DTS Package..."); DTS.Package2Class package =new DTS.Package2Class();object pVarPersistStgOfHost =null;package.LoadFromSQLServer("192.168.8.8","username","thepassword",Microsoft.SqlServer.DTSPkg80.DTSSQLServerStorageFlags.DTSSQLStgFlag_Default,null,null,null,(string)ConfigurationSettings.AppSettings["productDTSPackage"],ref pVarPersistStgOfHost);package.GlobalVariables.Item(1).Value = f.FullName.ToString();package.Execute();package.UnInitialize();//force release of COM objectSystem.Runtime.InteropServices.Marshal.ReleaseComObject(package);package =null;}catch(Exception e){activity.Log(string.Format("Failureprocessing {0}",WorkingPath + f.Name) +" - "+ e.Message);}

and the activex i tried to use for the transformations is:

'**********************************************************************
' Visual Basic Transformation Script
'************************************************************************

' Copy each source column to the destination column
Function Main()
DTSDestination("Yesmail Id") = DTSSource("product series")
DTSDestination("Customer CKM CustId") = DTSSource("product family")
DTSDestination("Product SKU") = DTSSource("transaction date")
DTSDestination("product model name") = DTSSource("serial number")
DTSDestination("serial number") = DTSSource("product model name")
DTSDestination("transaction date") = DTSSource("Product SKU")
DTSDestination("product family") = DTSSource("Customer CKM CustId")
DTSDestination("product series") = DTSSource("Yesmail Id")
DTSDestination("fileName") = DTSGlobalVariables("sourceFile").Value <-- this is why im using the activex for this field to get a Global Variable.
Main = DTSTransformStat_OK
End Function

the weird thing is the PACKAGE runs fine from ENTERPRISE MANAGER with this activex, it just doesn't do it from my Calling app, perhaps i have missed something i need to change in the package constructor?

BTW: i do have my assembly signed in C# for the COM wrapper.

thanks in advance,

mcm

I have answered here in the other thread the next step and it is not complicated and I have not found anybody who could not get it to run so run a search on this site for setting up the proxy account link. Hope this helps.

http://forums.asp.net/thread/1440879.aspx

Monday, March 19, 2012

Calling a task within a task

Hi!
Is is possible to call a SQL task within an ActiveX script task?Hi!

Is is possible to call a SQL task within an ActiveX script task?

Look at SQLDMO in BOL.

Regards,

hmscott

Saturday, February 25, 2012

call a program (activex exe, dll or something) from a script

Is it possible to do this? I am evaluating a bunch of possible solutions to
a problem. Someone came up with this idea, but could not remember for
certain if it possible.
Thanks.1. Lookup the sp_OAxxxxxx routines in SQL Online Books and it will show you
how to create COM objects and call method and set properties
2. Lookup xp_cmdshell on how to launch processes
3. Write an extended stored proc to have tighter control over what is
happening (inside your proc you can call CreateProcess() API and do many
other things)
All three of these options have security/stability implications. Let me
know if you need more details on a specific option.
Mike
"Stephanie" <IwishICould@.NoWay.com> wrote in message
news:O8qomUBTFHA.2916@.TK2MSFTNGP15.phx.gbl...
> Is it possible to do this? I am evaluating a bunch of possible solutions
to
> a problem. Someone came up with this idea, but could not remember for
> certain if it possible.
> Thanks.
>