Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: DTS Package Connection Syntax


Message #1 by Karen Martin <kmartin@a...> on Fri, 30 Mar 2001 12:43:19 +0100
It's OK!  Managed to sort it. :-)
Thanks everyone.

-----Original Message-----
From: Karen Martin [mailto:kmartin@a...]
Sent: 30 March 2001 12:43
To: professional vb
Subject: [pro_vb] DTS Package Connection Syntax



Hello,

Can anyone please tell me what is wrong with this following code?
This procedure is called from a module to connect to DTS on a SQL server
(version 7).  The .ADD = is highlighted by the following error message when
run: Compile Error: Argument not optional.  And, the constant variables are
declared in the general declarations of the module, so should be available
to this procedure.


Private Sub ServerConnection( )

Dim objConnection As DTS.Connection
Dim objPackage As DTS.Package

' Create the connection object
' The package is already created at this point
Set objConnection = objPackage.Connections.New("SQLOLEDB")
    With objConnection
        .ID = 1
        .DataSource = cnsDataSource
        .Catalog = cnsCatalog
        .UseTrustedConnection = True
    End With
    Set objPackage.Connections.Add = objConnection
                
    Set objConnection = Nothing
    Set objPackage = Nothing

End Sub


Thanks everyone.



Karen Martin
Payment Systems Technical Specialist
Alphatec Software
Email: kmartin@a...



>  -----Original Message-----
> From: 	Karen Martin  
> Sent:	30 March 2001 11:13
> To:	'pro_vb@p...'
> Subject:	
> 
> 
> Hello,
> 
> Can anyone please tell me what is wrong with this following code?
> This procedure is called from a module to connect to DTS on a SQL server
> (version 7).  The .ADD = is highlighted by the following error message
> when run: Compile Error: Argument not optional.  And, the constant
> variables are declared in the general declarations of the module, so
> should be available to this procedure.
> 
> 
> Private Sub ServerConnection( )
> 
> Dim objConnection As DTS.Connection
> Dim objPackage As DTS.Package
> 
> ' Create the connection object
> ' The package is already created at this point
> Set objConnection = objPackage.Connections.New("SQLOLEDB")
>     With objConnection
>         .ID = 1
>         .DataSource = cnsDataSource
>         .Catalog = cnsCatalog
>         .UseTrustedConnection = True
>     End With
>     Set objPackage.Connections.Add = objConnection
>                 
>     Set objConnection = Nothing
>     Set objPackage = Nothing
> 
> End Sub
> 
> 
> Thanks everyone.
> 
> 
> 
> Karen Martin
> Payment Systems Technical Specialist
> Alphatec Software
> Email: kmartin@a...
> 


  Return to Index