dbTalk Databases Forums  

Executing a DTS Package from VB.NET forms

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Executing a DTS Package from VB.NET forms in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
damian_meleo@hotmail.com
 
Posts: n/a

Default Executing a DTS Package from VB.NET forms - 09-18-2006 , 01:44 AM






Hi,

I am getting an error "[DBNETLIB][ConnectionOpen (Connect()).]SQL
Server does not exist or access denied." when I try and execute a DTS
package from VB.NET (forms) using the method LoadFromSQLServer.

I am trying to execute a package from a remote SQL Server. The package
has one connection in it and I use the Server name not (Local) and use
SQL Server authentication ( the user has priviliges on the database). I
can execute the package through Enterprise Manager successfully if i
log into the machine.

I created the package under my windows account ( which is a domain
admin)
I want this windows app to be used by other people so the parameters I
used for the method
LoadFromSQLServer were "server name" , "username", "password",
DTSSQLStgFlag_UseTrustedConnection flag and "package name".

Should I be using my account details for username and password? I can
execute the package if i log into the SQL Server (under my account)

Any help will be appreciated

Cheers
Damian


Reply With Quote
  #2  
Old   
Charles Kangai
 
Posts: n/a

Default RE: Executing a DTS Package from VB.NET forms - 09-27-2006 , 11:43 AM






Hi Damian,

The reason you are having trouble is that, from .NET's point of view, you're
trying to call COM DLLs from .NET code. You need to wrap your COM DLL in
something .NET can talk to:
Therefore you need to do four things:

1) Create a strong name key pair file using sn.exe. This enables you to
create an assembly that is uniquely identifiable. Switch to the folder
c:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin and execute:

e.g. sn.exe –k C:\MyDTSKey.KEY

2) Use TlbImp.exe (Type Library Import) to import the main DTS DLL file into
a runtime callable wrapper (RCW) DLL to enable COM to interact with .NET.
e.g. Tlbimp.exe "c:\Program Files\Microsoft SQL
Server\80\Tools\Binn\dtspkg.dll"
/out:c:\Microsoft.SqlServer.DTSPkgDotNet.dll /keyfile:C:\MyDTSKey.KEY

3) Register the RCW in the GAC (Global Assembly Cache):
Gacutil.exe –I c:\Microsoft.SqlServer.DTSPkgDotNet.dll

4) Reference this file in your .NET code.

You're good to go!

Charles Kangai, MCT, MCDBA
Author of Learning Tree's 4-day course: "SQL Server 2005 Integration
Services" http://www.learningtree.com/courses/134.htm
Author of Learning Tree's 4-day course: "SQL Server Reporting Services"
http://www.learningtree.com/courses/523.htm
email alias: charles
email domain: kangai.demon.co.uk



"damian_meleo (AT) hotmail (DOT) com" wrote:

Quote:
Hi,

I am getting an error "[DBNETLIB][ConnectionOpen (Connect()).]SQL
Server does not exist or access denied." when I try and execute a DTS
package from VB.NET (forms) using the method LoadFromSQLServer.

I am trying to execute a package from a remote SQL Server. The package
has one connection in it and I use the Server name not (Local) and use
SQL Server authentication ( the user has priviliges on the database). I
can execute the package through Enterprise Manager successfully if i
log into the machine.

I created the package under my windows account ( which is a domain
admin)
I want this windows app to be used by other people so the parameters I
used for the method
LoadFromSQLServer were "server name" , "username", "password",
DTSSQLStgFlag_UseTrustedConnection flag and "package name".

Should I be using my account details for username and password? I can
execute the package if i log into the SQL Server (under my account)

Any help will be appreciated

Cheers
Damian



Reply With Quote
  #3  
Old   
Charles Kangai
 
Posts: n/a

Default RE: Executing a DTS Package from VB.NET forms - 09-27-2006 , 11:54 AM



Here is sample code to run from VB.NET:

Imports Microsoft.SQLServer.DTSDotNetPkg

Module MyPackage

Sub Main()
Dim package As New DTS.Package2Class
Dim filename As String = "C:\Packages\SomePackage.dts"
Dim pwd As String = ""
Dim packageGUID As String = ""
Dim versionGUID As String = ""
Dim name As String = "MyPackage"
'package.LoadFromSQLServer("(local)", "sa", "sapw", , , , , name, "")
package.LoadFromStorageFile(filename, "", , , name, )
package.Execute()
package.UnInitialize()
package = Nothing
End Sub


Charles Kangai, MCT, MCDBA
Author of Learning Tree's 4-day course: "SQL Server 2005 Integration
Services" http://www.learningtree.com/courses/134.htm
Author of Learning Tree's 4-day course: "SQL Server Reporting Services"
http://www.learningtree.com/courses/523.htm
email alias: charles
email domain: kangai.demon.co.uk




"Charles Kangai" wrote:

Quote:
Hi Damian,

The reason you are having trouble is that, from .NET's point of view, you're
trying to call COM DLLs from .NET code. You need to wrap your COM DLL in
something .NET can talk to:
Therefore you need to do four things:

1) Create a strong name key pair file using sn.exe. This enables you to
create an assembly that is uniquely identifiable. Switch to the folder
c:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin and execute:

e.g. sn.exe –k C:\MyDTSKey.KEY

2) Use TlbImp.exe (Type Library Import) to import the main DTS DLL file into
a runtime callable wrapper (RCW) DLL to enable COM to interact with .NET.
e.g. Tlbimp.exe "c:\Program Files\Microsoft SQL
Server\80\Tools\Binn\dtspkg.dll"
/out:c:\Microsoft.SqlServer.DTSPkgDotNet.dll /keyfile:C:\MyDTSKey.KEY

3) Register the RCW in the GAC (Global Assembly Cache):
Gacutil.exe –I c:\Microsoft.SqlServer.DTSPkgDotNet.dll

4) Reference this file in your .NET code.

You're good to go!

Charles Kangai, MCT, MCDBA
Author of Learning Tree's 4-day course: "SQL Server 2005 Integration
Services" http://www.learningtree.com/courses/134.htm
Author of Learning Tree's 4-day course: "SQL Server Reporting Services"
http://www.learningtree.com/courses/523.htm
email alias: charles
email domain: kangai.demon.co.uk



"damian_meleo (AT) hotmail (DOT) com" wrote:

Hi,

I am getting an error "[DBNETLIB][ConnectionOpen (Connect()).]SQL
Server does not exist or access denied." when I try and execute a DTS
package from VB.NET (forms) using the method LoadFromSQLServer.

I am trying to execute a package from a remote SQL Server. The package
has one connection in it and I use the Server name not (Local) and use
SQL Server authentication ( the user has priviliges on the database). I
can execute the package through Enterprise Manager successfully if i
log into the machine.

I created the package under my windows account ( which is a domain
admin)
I want this windows app to be used by other people so the parameters I
used for the method
LoadFromSQLServer were "server name" , "username", "password",
DTSSQLStgFlag_UseTrustedConnection flag and "package name".

Should I be using my account details for username and password? I can
execute the package if i log into the SQL Server (under my account)

Any help will be appreciated

Cheers
Damian



Reply With Quote
  #4  
Old   
damian_meleo@hotmail.com
 
Posts: n/a

Default Re: Executing a DTS Package from VB.NET forms - 09-28-2006 , 06:13 PM



Hi Charles,


Thanks for your help. WIll try and see how it goes.
Much appreciated.

Regards
Damian


Charles Kangai wrote:
Quote:
Here is sample code to run from VB.NET:

Imports Microsoft.SQLServer.DTSDotNetPkg

Module MyPackage

Sub Main()
Dim package As New DTS.Package2Class
Dim filename As String = "C:\Packages\SomePackage.dts"
Dim pwd As String = ""
Dim packageGUID As String = ""
Dim versionGUID As String = ""
Dim name As String = "MyPackage"
'package.LoadFromSQLServer("(local)", "sa", "sapw", , , , , name, "")
package.LoadFromStorageFile(filename, "", , , name, )
package.Execute()
package.UnInitialize()
package = Nothing
End Sub


Charles Kangai, MCT, MCDBA
Author of Learning Tree's 4-day course: "SQL Server 2005 Integration
Services" http://www.learningtree.com/courses/134.htm
Author of Learning Tree's 4-day course: "SQL Server Reporting Services"
http://www.learningtree.com/courses/523.htm
email alias: charles
email domain: kangai.demon.co.uk




"Charles Kangai" wrote:

Hi Damian,

The reason you are having trouble is that, from .NET's point of view, you're
trying to call COM DLLs from .NET code. You need to wrap your COM DLL in
something .NET can talk to:
Therefore you need to do four things:

1) Create a strong name key pair file using sn.exe. This enables you to
create an assembly that is uniquely identifiable. Switch to the folder
c:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin and execute:

e.g. sn.exe -k C:\MyDTSKey.KEY

2) Use TlbImp.exe (Type Library Import) to import the main DTS DLL file into
a runtime callable wrapper (RCW) DLL to enable COM to interact with .NET.
e.g. Tlbimp.exe "c:\Program Files\Microsoft SQL
Server\80\Tools\Binn\dtspkg.dll"
/out:c:\Microsoft.SqlServer.DTSPkgDotNet.dll /keyfile:C:\MyDTSKey.KEY

3) Register the RCW in the GAC (Global Assembly Cache):
Gacutil.exe -I c:\Microsoft.SqlServer.DTSPkgDotNet.dll

4) Reference this file in your .NET code.

You're good to go!

Charles Kangai, MCT, MCDBA
Author of Learning Tree's 4-day course: "SQL Server 2005 Integration
Services" http://www.learningtree.com/courses/134.htm
Author of Learning Tree's 4-day course: "SQL Server Reporting Services"
http://www.learningtree.com/courses/523.htm
email alias: charles
email domain: kangai.demon.co.uk



"damian_meleo (AT) hotmail (DOT) com" wrote:

Hi,

I am getting an error "[DBNETLIB][ConnectionOpen (Connect()).]SQL
Server does not exist or access denied." when I try and execute a DTS
package from VB.NET (forms) using the method LoadFromSQLServer.

I am trying to execute a package from a remote SQL Server. The package
has one connection in it and I use the Server name not (Local) and use
SQL Server authentication ( the user has priviliges on the database). I
can execute the package through Enterprise Manager successfully if i
log into the machine.

I created the package under my windows account ( which is a domain
admin)
I want this windows app to be used by other people so the parameters I
used for the method
LoadFromSQLServer were "server name" , "username", "password",
DTSSQLStgFlag_UseTrustedConnection flag and "package name".

Should I be using my account details for username and password? I can
execute the package if i log into the SQL Server (under my account)

Any help will be appreciated

Cheers
Damian




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.